linea21-core
[ class tree: linea21-core ] [ index: linea21-core ] [ all elements ]

Source for file template.php

Documentation is available at template.php

  1. <?php
  2. /**
  3.  * @package linea21.core
  4.  * @subpackage mail
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11.  
  12. require_once '../lib/vendor/swift/lib/swift_required.php';
  13.  
  14. // We create the Transport
  15. if (defined('MAIL_MAILER')) {
  16.     
  17.     // by default
  18.     $transport Swift_MailTransport::newInstance();
  19.  
  20.     // sendmail
  21.     if(MAIL_MAILER=='sendmail'{
  22.         
  23.         $transport Swift_SendmailTransport::newInstance(MAIL_SENDMAIL);
  24.         
  25.     }
  26.     // smtp
  27.     if(MAIL_MAILER=='smtp'{
  28.         if(defined('MAIL_SMTP_AUTH'&& MAIL_SMTP_AUTH == 1{
  29.             
  30.             $transport Swift_SmtpTransport::newInstance(MAIL_HOSTMAIL_PORT)
  31.             ->setUsername(MAIL_SMTP_USER)
  32.             ->setPassword(MAIL_SMTP_PASS);
  33.             
  34.         else {
  35.             
  36.             $transport Swift_SmtpTransport::newInstance(MAIL_HOSTMAIL_PORT);
  37.             
  38.         }
  39.  
  40.     }
  41.     
  42. }
  43.  
  44.  
  45. /**
  46.  echo "destinataire : ".$email_recipient."<br />";
  47.  echo "sujet : ".$email_subject."<br />";
  48.  echo "body : ".$email_html_body."<br />";
  49.  echo "methode : ".$email_method."<br />";
  50.  echo "host : ".$mail->Host."<br />";
  51.  echo "port : ".$mail->Port."<br />";
  52.  */
  53.  
  54. // Create the Mailer using the Transport
  55. $mailer Swift_Mailer::newInstance($transport);
  56.  
  57.  
  58. isset($email_from$from $email_from $from MAIL_FROM;
  59. isset($email_fromname$fromname $email_fromname $fromname MAIL_FROMNAME;
  60. $altbody str_replace('&amp;''&'$email_text_body);
  61.  
  62. // if only one email is given we put it an array
  63. if(is_string($email_recipient)) {
  64.     $tmp $email_recipient;
  65.     $email_recipient array();
  66.     array_push($email_recipient$tmp);
  67. }
  68.  
  69. // Create a message
  70. $message Swift_Message::newInstance($email_subject)
  71.                     ->setFrom(array($from => $fromname))
  72.                     ->setBody($email_html_body'text/html')
  73.                     ->addPart($altbody'text/plain')
  74.                     ->setReplyTo(array(MAIL_REPLY => MAIL_REPLYNAME))
  75.                     ;
  76.                     
  77.  
  78.                     
  79. if(is_array($email_recipient)) {
  80.     
  81.     for($i=0$i<count($email_recipient)$i++{
  82.  
  83.         $message->setTo($email_recipient[$i]);
  84.         $r $mailer->Send($message$failures);
  85.         
  86.         if(!$r
  87.             $logmsg 'not sent';
  88.         else {
  89.             $logmsg 'sent';
  90.         }
  91.         
  92.         logfile(LOG_MAILERarray($email_subject$email_recipient[$i]$logmsg));
  93.         if(!$r && MOD_DEBUG == 1{
  94.             _debug('<b>Mail has not been sent</b>. "'$email_recipient[$i.' / '.$email_subject.'" : ' .$logmsg);
  95.         }
  96.  
  97.  
  98.     }
  99.     
  100. }
  101.  
  102.  
  103. ?>

Documentation generated on Mon, 08 Apr 2013 18:16:25 +0200 by phpDocumentor 1.4.1