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. // preparing footer
  63. $html_footer _t('mail''footer');
  64. $html_footer .= "<br />-------------------<br />";
  65. $html_footer .= "<small><a href=\"".SITE_ROOT_URL"public/\">".SITE_NAME."</a> - <a href=\"mailto:".SITE_MAIL"\">"._t('contact','contact_us')."</a></small>";
  66.  
  67. $txt_footer strip_tags(_t('mail''footer'));
  68. $txt_footer .= "\n-------------------\n";
  69. $txt_footer .= SITE_ROOT_URL"public/ - "._t('contact','contact_us')." : ".SITE_MAIL;
  70.  
  71. // We add greetings to content
  72. $email_html_body _t('mail''header_hello')."<br /><br />".$email_html_body$html_footer;
  73. $email_html_body '<div style="font-family: Arial, Helvetica, sans-serif;">'$email_html_body'</div>';
  74. $altbody _t('mail''header_hello')."\n\n".$altbody$txt_footer;
  75.  
  76. // if only one email is given we put it an array
  77. if(is_string($email_recipient)) {
  78.     $tmp $email_recipient;
  79.     $email_recipient array();
  80.     array_push($email_recipient$tmp);
  81. }
  82.  
  83. // Create a message
  84. $message Swift_Message::newInstance($email_subject)
  85.                     ->setFrom(array($from => $fromname))
  86.                     ->setBody($email_html_body'text/html')
  87.                     ->addPart($altbody'text/plain')
  88.                     ->setReplyTo(array(MAIL_REPLY => MAIL_REPLYNAME))
  89.                     ;
  90.                     
  91.  
  92.                     
  93. if(is_array($email_recipient)) {
  94.     
  95.     for($i=0$i<count($email_recipient)$i++{
  96.  
  97.         $message->setTo($email_recipient[$i]);
  98.         $r $mailer->Send($message$failures);
  99.         
  100.         if(!$r
  101.             $logmsg 'not sent';
  102.         else {
  103.             $logmsg 'sent';
  104.         }
  105.         
  106.         logfile(LOG_MAILERarray($email_subject$email_recipient[$i]$logmsg));
  107.         if(!$r && MOD_DEBUG == 1{
  108.             _debug('<b>Mail has not been sent</b>. "'$email_recipient[$i.' / '.$email_subject.'" : ' .$logmsg);
  109.         }
  110.  
  111.  
  112.     }
  113.     
  114. }
  115.  
  116.  
  117. ?>

Documentation generated on Thu, 20 Mar 2014 16:49:34 +0100 by phpDocumentor 1.4.1