[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * TODO: Should be final, but inherited by SES. 5 */ 6 class PhabricatorMailImplementationPHPMailerLiteAdapter 7 extends PhabricatorMailImplementationAdapter { 8 9 /** 10 * @phutil-external-symbol class PHPMailerLite 11 */ 12 public function __construct() { 13 $root = phutil_get_library_root('phabricator'); 14 $root = dirname($root); 15 require_once $root.'/externals/phpmailer/class.phpmailer-lite.php'; 16 $this->mailer = new PHPMailerLite($use_exceptions = true); 17 $this->mailer->CharSet = 'utf-8'; 18 19 $encoding = PhabricatorEnv::getEnvConfig('phpmailer.smtp-encoding', '8bit'); 20 $this->mailer->Encoding = $encoding; 21 22 // By default, PHPMailerLite sends one mail per recipient. We handle 23 // multiplexing higher in the stack, so tell it to send mail exactly 24 // like we ask. 25 $this->mailer->SingleTo = false; 26 } 27 28 public function supportsMessageIDHeader() { 29 return true; 30 } 31 32 public function setFrom($email, $name = '') { 33 $this->mailer->SetFrom($email, $name, $crazy_side_effects = false); 34 return $this; 35 } 36 37 public function addReplyTo($email, $name = '') { 38 $this->mailer->AddReplyTo($email, $name); 39 return $this; 40 } 41 42 public function addTos(array $emails) { 43 foreach ($emails as $email) { 44 $this->mailer->AddAddress($email); 45 } 46 return $this; 47 } 48 49 public function addCCs(array $emails) { 50 foreach ($emails as $email) { 51 $this->mailer->AddCC($email); 52 } 53 return $this; 54 } 55 56 public function addAttachment($data, $filename, $mimetype) { 57 $this->mailer->AddStringAttachment( 58 $data, 59 $filename, 60 'base64', 61 $mimetype); 62 return $this; 63 } 64 65 public function addHeader($header_name, $header_value) { 66 if (strtolower($header_name) == 'message-id') { 67 $this->mailer->MessageID = $header_value; 68 } else { 69 $this->mailer->AddCustomHeader($header_name.': '.$header_value); 70 } 71 return $this; 72 } 73 74 public function setBody($body) { 75 $this->mailer->Body = $body; 76 $this->mailer->IsHTML(false); 77 return $this; 78 } 79 80 81 /** 82 * Note: phpmailer-lite does NOT support sending messages with mixed version 83 * (plaintext and html). So for now lets just use HTML if it's available. 84 * @param $html 85 */ 86 public function setHTMLBody($html_body) { 87 $this->mailer->Body = $html_body; 88 $this->mailer->IsHTML(true); 89 return $this; 90 } 91 92 public function setSubject($subject) { 93 $this->mailer->Subject = $subject; 94 return $this; 95 } 96 97 public function hasValidRecipients() { 98 return true; 99 } 100 101 public function send() { 102 return $this->mailer->Send(); 103 } 104 105 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |