Advertisement
Guest User

Untitled

a guest
Feb 26th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. $mailer->AddAddress("aa@gmail.com");
  2.  
  3. $mailer->AddAddress("aaa@gmail.com, bbbb@gmail.com");
  4. $mailer->AddAddress("'aaa@gmail.com', 'bbbb@gmail.com'");
  5. $mailer->AddAddress(""aaa@gmail.com", "bbbb@gmail.com"");
  6.  
  7. $mailer->AddAddress("aaa@gmail.com");
  8. $mailer->AddAddress("bbbb@gmail.com");
  9.  
  10. <?php
  11.  
  12. Yii::import('application.extensions.PHPMailer_v5.1.*');
  13.  
  14. class Mailer {
  15.  
  16. private $mail;
  17.  
  18. public function initialise() {
  19. try {
  20. require Yii::getPathOfAlias('application.extensions') . '/PHPMailer_v5.1/class.phpmailer.php';
  21. $this->mail = new PHPMailer(TRUE);
  22. $this->mail->IsSMTP(); // tell the class to use SMTP
  23. $this->mail->SMTPDebug = 0;
  24. $this->mail->SMTPAuth = true; // enable SMTP authentication
  25. $this->mail->Port = 25; // set the SMTP server port
  26. $this->mail->Host = "smtp.test.net"; // SMTP server
  27. $this->mail->Username = "test.com"; // SMTP server username
  28. $this->mail->Password = "test"; // SMTP server password
  29. $this->mail->Mailer = "smtp";
  30. $this->mail->From = 'info@test.com';
  31. $this->mail->FromName = 'test@net.com';
  32. } catch (Exception $e) {
  33. echo $e->getTraceAsString();
  34. }
  35. }
  36.  
  37. public function email($message, $sendTo, $subject) {
  38. try {
  39. $this->mail->AddAddress($sendTo);
  40. $this->mail->Subject = $subject;
  41. $body = $message;
  42. $this->mail->MsgHTML($body);
  43. $this->mail->IsHTML(true); // send as HTML
  44. $this->mail->Send();
  45. $this->mail->ClearAllRecipients();
  46. } catch (Exception $e) {
  47. echo $e->getTraceAsString();
  48. }
  49. }
  50.  
  51. }
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement