Changeset View
Changeset View
Standalone View
Standalone View
externals/phpmailer/class.phpmailer-lite.php
| Show All 36 Lines | |||||
| * @version $Id: class.phpmailer-lite.php 447 2009-09-12 13:21:38Z codeworxtech $ | * @version $Id: class.phpmailer-lite.php 447 2009-09-12 13:21:38Z codeworxtech $ | ||||
| * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License | ||||
| */ | */ | ||||
| if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n"); | if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n"); | ||||
| class PHPMailerLite { | class PHPMailerLite { | ||||
| public static function newFromMessage( | |||||
| PhabricatorMailExternalMessage $message) { | |||||
| $mailer = new self($use_exceptions = true); | |||||
| // By default, PHPMailerLite sends one mail per recipient. We handle | |||||
| // combining or separating To and Cc higher in the stack, so tell it to | |||||
| // send mail exactly like we ask. | |||||
| $mailer->SingleTo = false; | |||||
| $mailer->CharSet = 'utf-8'; | |||||
| $mailer->Encoding = 'base64'; | |||||
| $subject = $message->getSubject(); | |||||
| if ($subject !== null) { | |||||
| $mailer->Subject = $subject; | |||||
| } | |||||
| $from_address = $message->getFromAddress(); | |||||
| if ($from_address) { | |||||
| $mailer->SetFrom( | |||||
| $from_address->getAddress(), | |||||
| (string)$from_address->getDisplayName(), | |||||
| $crazy_side_effects = false); | |||||
| } | |||||
| $reply_address = $message->getReplyToAddress(); | |||||
| if ($reply_address) { | |||||
| $mailer->AddReplyTo( | |||||
| $reply_address->getAddress(), | |||||
| (string)$reply_address->getDisplayName()); | |||||
| } | |||||
| $to_addresses = $message->getToAddresses(); | |||||
| if ($to_addresses) { | |||||
| foreach ($to_addresses as $address) { | |||||
| $mailer->AddAddress( | |||||
| $address->getAddress(), | |||||
| (string)$address->getDisplayName()); | |||||
| } | |||||
| } | |||||
| $cc_addresses = $message->getCCAddresses(); | |||||
| if ($cc_addresses) { | |||||
| foreach ($cc_addresses as $address) { | |||||
| $mailer->AddCC( | |||||
| $address->getAddress(), | |||||
| (string)$address->getDisplayName()); | |||||
| } | |||||
| } | |||||
| $headers = $message->getHeaders(); | |||||
| if ($headers) { | |||||
| foreach ($headers as $header) { | |||||
amckinley: Still an unused variable. | |||||
| $name = $header->getName(); | |||||
| $value = $header->getValue(); | |||||
| if (phutil_utf8_strtolower($name) === 'message-id') { | |||||
| $mailer->MessageID = $value; | |||||
| } else { | |||||
| $mailer->AddCustomHeader("{$name}: {$value}"); | |||||
| } | |||||
| } | |||||
| } | |||||
| $attachments = $message->getAttachments(); | |||||
| if ($attachments) { | |||||
| foreach ($attachments as $attachment) { | |||||
| $mailer->AddStringAttachment( | |||||
| $attachment->getData(), | |||||
| $attachment->getFilename(), | |||||
| 'base64', | |||||
| $attachment->getMimeType()); | |||||
| } | |||||
| } | |||||
| $text_body = $message->getTextBody(); | |||||
| if ($text_body !== null) { | |||||
| $mailer->Body = $text_body; | |||||
| } | |||||
| $html_body = $message->getHTMLBody(); | |||||
| if ($html_body !== null) { | |||||
| $mailer->IsHTML(true); | |||||
| $mailer->Body = $html_body; | |||||
| if ($text_body !== null) { | |||||
| $mailer->AltBody = $text_body; | |||||
| } | |||||
| } | |||||
| return $mailer; | |||||
| } | |||||
| ///////////////////////////////////////////////// | ///////////////////////////////////////////////// | ||||
| // PROPERTIES, PUBLIC | // PROPERTIES, PUBLIC | ||||
| ///////////////////////////////////////////////// | ///////////////////////////////////////////////// | ||||
| /** | /** | ||||
| * Email priority (1 = High, 3 = Normal, 5 = low). | * Email priority (1 = High, 3 = Normal, 5 = low). | ||||
| * @var int | * @var int | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 2,034 Lines • Show Last 20 Lines | |||||
Still an unused variable.