Il mio mail server non consente l'utilizzo del "semplice" smtp server come configurato in joomla.
Un amico mi ha passato XPertMailer.
Preparata questa pagina php per il richiamo della libreria XPert,
Code: Select all
<?php
global $mosConfig_absolute_path
require_once $mosConfig_absolute_path . ('/includes/XPertMailer.php');
require_once $mosConfig_absolute_path . ('/configuration.php');
$emailmethod=5; // The following values can be used:
// 1 = SMTP_LOCAL - Localhost
// 2 = SMTP_CLIENT - MX host name(s)
// 3 = SMTP_LOCAL_CLIENT - 1'st SMTP_LOCAL, 2'nd if fail try SMTP_CLIENT
// 4 = SMTP_CLIENT_LOCAL - 1'st SMTP_CLIENT, 2'nd if fail try SMTP_LOCAL
// 5 = SMTP_RELAY - Relay MX host name(s) or ip address with optional authorisation
// 6 = SMTP_RELAY_CLIENT, - 1'st SMTP_RELAY, 2'nd if fail try SMTP_CLIENT
// 7 = SMTP_CLIENT_RELAY - 1'st SMTP_CLIENT, 2'nd if fail try SMTP_RELAY
function MailTextMessage($body, $subject, $to, $from, $sitename)
{
global $emailmethod, $mosConfig_smtphost, $mosConfig_smtpuser, $mosConfig_smtppass;
$mail = new XpertMailer($emailmethod,$mosConfig_smtphost);
if (($emailmethod ==5 || $emailmethod ==6 || $emailmethod ==7) && $mosConfig_smtpuser!="" )
{ $mail->auth($mosConfig_smtpuser,$mosConfig_smtppass);
}
$fromname='';
$fromemail=$from;
if (strpos($from,'<'))
{
$fromemail=substr($from,strpos($from,'<')+1,strpos($from,'>')-1-strpos($from,'<'));
$fromname=trim(substr($from,0, strpos($from,'<')-1));
}
$mail->from($fromemail, $fromname);
$header['X-Mailer'] = $sitename;
$mail->headers($header);
$body = strip_tags($body);
$body = str_replace(""", '"', $body);
if (get_magic_quotes_gpc() != "0") {$body = stripcslashes($body);}
$subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
Return $mail->send($to, $subject, $body, false, 'utf-8');
}
//$to='[email protected]';[/color]
MailTextMessage($body, $subject, $to, $mosConfig_mailfrom, $mosConfig_live_site );
?>
Ho provato a inserire questa pagina in mosmail (/includes/joomla.php).
Avendo, infatti, aggiunto alla array dell'admin la stringa
Code: Select all
// MAIL SETTINGS
$mailer = array(
mosHTML::makeOption( 'mail', 'PHP mail function' ),
mosHTML::makeOption( 'sendmail', 'Sendmail' ),
mosHTML::makeOption( 'smtp', 'SMTP Server' ),
mosHTML::makeOption( 'mailer', 'XPertMailer' ),
);
Nella funzione mosmail, poi, ho aggiunto un
Code: Select all
if ($mosConfig_mailer == 'mailer');
Non funziona, ovviamente. Sarebbe stato troppo facile.
Qualcuno che mi dia una indicazione su come integrare?
Ho visto, comunque, che l'argomento è molto discusso e, quindi, allego anche la libreria XPertmailer.
Grazie
edit: Dimenticavo, in questo codice, fromname e fromemail sono uguali in quanto così pretende il mail server. L'email DEVE contenere in entrambi i campi il nome del titolare della casella