Advertisement
Guest User

Untitled

a guest
Feb 26th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Class GEmailLogRoute
  5.  */
  6. class GEmailLogRoute extends CLogRoute
  7. {
  8.     public $port = 465;
  9.     public $host;
  10.     public $smtpAuth = true;
  11.     public $smtpSecure = 'SSL';
  12.     public $isHtml = true;
  13.     public $username;
  14.     public $password;
  15.     public $to = [];
  16.  
  17.     /**
  18.      * @param $email
  19.      * @param $subject
  20.      * @param $body
  21.      */
  22.     protected function sendEmail($email, $subject, $body)
  23.     {
  24.         $mailer = Yii::createComponent('application.extensions.mailer.EMailer');
  25.  
  26.         $mailer->IsSMTP();
  27.         $mailer->Host = $this->host;
  28.         $mailer->SMTPAuth = $this->smtpAuth;
  29.         $mailer->SMTPSecure = $this->smtpSecure;
  30.         $mailer->isHTML($this->isHtml);
  31.         $mailer->Port = $this->port;
  32.         $mailer->Username = $this->username;
  33.         $mailer->From = $this->username;
  34.         $mailer->FromName = $this->username;
  35.         $mailer->AddReplyTo($this->username);
  36.         $mailer->Password = $this->password;
  37.  
  38.         $mailer->AddAddress($email);
  39.  
  40.         $mailer->CharSet = 'UTF-8';
  41.         $mailer->Subject = $subject;
  42.         $mailer->Body = $body;
  43.         $mailer->Send();
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement