Source for file template.php
Documentation is available at template.php
* @author linea21 <info@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
require_once '../lib/vendor/swift/lib/swift_required.php';
// We create the Transport
$transport = Swift_MailTransport::newInstance();
if(MAIL_MAILER== 'sendmail') {
$transport = Swift_SendmailTransport::newInstance(MAIL_SENDMAIL);
if(MAIL_MAILER== 'smtp') {
if(defined('MAIL_SMTP_AUTH') && MAIL_SMTP_AUTH == 1) {
$transport = Swift_SmtpTransport::newInstance(MAIL_HOST, MAIL_PORT)
->setUsername(MAIL_SMTP_USER)
->setPassword(MAIL_SMTP_PASS);
$transport = Swift_SmtpTransport::newInstance(MAIL_HOST, MAIL_PORT);
echo "destinataire : ".$email_recipient."<br />";
echo "sujet : ".$email_subject."<br />";
echo "body : ".$email_html_body."<br />";
echo "methode : ".$email_method."<br />";
echo "host : ".$mail->Host."<br />";
echo "port : ".$mail->Port."<br />";
// Create the Mailer using the Transport
$mailer = Swift_Mailer::newInstance($transport);
isset ($email_from) ? $from = $email_from : $from = MAIL_FROM;
isset ($email_fromname) ? $fromname = $email_fromname : $fromname = MAIL_FROMNAME;
$altbody = str_replace('&', '&', $email_text_body);
// if only one email is given we put it an array
$email_recipient = array();
$message = Swift_Message::newInstance($email_subject)
->setFrom(array($from => $fromname))
->setBody($email_html_body, 'text/html')
->addPart($altbody, 'text/plain')
->setReplyTo(array(MAIL_REPLY => MAIL_REPLYNAME))
for($i= 0; $i< count($email_recipient); $i++ ) {
$message->setTo($email_recipient[$i]);
$r = $mailer->Send($message, $failures);
logfile(LOG_MAILER, array($email_subject, $email_recipient[$i], $logmsg));
if(!$r && MOD_DEBUG == 1) {
_debug('<b>Mail has not been sent</b>. "'. $email_recipient[$i] . ' / '. $email_subject. '" : ' . $logmsg);
|