示例#1
0
 /**
  * "send" an email. To do it, store an email into db and a crontask will pull emails to send them.
  * the crontask will be executed using the command line yiic sendmail.
  * @param unknown $to
  * @param unknown $subject
  * @param unknown $body
  */
 public static function sendMail($to, $subject, $body)
 {
     $mailq = new mailqueue();
     try {
         $headers = 'MIME-Version: 1.0' . "\r\n";
         $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
         $headers .= 'From: ' . CommonProperties::$SMTP_SENDER_FROM_EMAIL . "\r\n" . 'Reply-To: ' . CommonProperties::$SMTP_SENDER_FROM_EMAIL . "\r\n" . 'X-Mailer: PHP/' . phpversion();
         $mailq->emailto = $to;
         $subject = "{$subject}";
         $mailq->subject = $subject;
         $mailq->body = $body;
         $mailq->headers = $headers;
         if (!$mailq->validate()) {
             Yii::log("pb sur validation mail", "error");
         }
         return $mailq->save();
     } catch (Exception $e) {
         Yii::log("exception sur save mail" . print_r($mailq->errors), "error");
     }
 }
示例#2
0
 /**
  * "send" an email. To do it, store an email into db and a crontask will pull emails to send them.
  * the crontask will be executed using the command line yiic sendmail.
  * @param unknown $to
  * @param unknown $subject
  * @param unknown $body
  */
 public static function sendMail($to, $subject, $body)
 {
     try {
         $mailq = new mailqueue();
         $headers = 'MIME-Version: 1.0' . "\r\n";
         $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
         $headers .= 'From: ' . CommonMailer::MAIL_FROM . "\r\n" . 'Reply-To: ' . CommonMailer::MAIL_FROM . "\r\n" . 'X-Mailer: PHP/' . phpversion();
         if (!CommonTools::isInDevMode()) {
             $mailq->emailto = $to;
         } else {
             $mailq->emailto = CommonMailer::MAIL_FROM;
             $subject = "Mail in dev_mod for {$to} : {$subject}";
         }
         $mailq->subject = $subject;
         $mailq->body = $body;
         $mailq->headers = $headers;
         return $mailq->save();
     } catch (Exception $e) {
         Yii::log("exception sur save mail", "error");
     }
 }