Differential D19002 Diff 45593 src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerLiteAdapter.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerLiteAdapter.php
<?php | <?php | ||||
/** | /** | ||||
* TODO: Should be final, but inherited by SES. | * TODO: Should be final, but inherited by SES. | ||||
*/ | */ | ||||
class PhabricatorMailImplementationPHPMailerLiteAdapter | class PhabricatorMailImplementationPHPMailerLiteAdapter | ||||
extends PhabricatorMailImplementationAdapter { | extends PhabricatorMailImplementationAdapter { | ||||
protected $mailer; | protected $mailer; | ||||
protected function validateOptions(array $options) { | |||||
PhutilTypeSpec::checkMap( | |||||
$options, | |||||
array( | |||||
'encoding' => 'string', | |||||
)); | |||||
} | |||||
public function newDefaultOptions() { | |||||
return array( | |||||
'encoding' => 'base64', | |||||
); | |||||
} | |||||
public function newLegacyOptions() { | |||||
return array( | |||||
'encoding' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-encoding'), | |||||
amckinley: Should this be `phpmailerlite.smtp-encoding`? | |||||
Not Done Inline ActionsThere's no such option. Historically, it was only possible to configure one mailer and they (PHPMailer and PHPMailerLite) shared this option, which could perhaps have been called any-mailer.smtp-encoding or similar, although here it's a sendmail encoding rather than an SMTP encoding, so any-mailer.mail-encoding, maybe. In practice, this should always be set to base64 everywhere, and that's been the default for a long time. The ability to configure this could probably just be removed completely. epriestley: There's no such option. Historically, it was only possible to configure one mailer and they… | |||||
); | |||||
} | |||||
/** | /** | ||||
* @phutil-external-symbol class PHPMailerLite | * @phutil-external-symbol class PHPMailerLite | ||||
*/ | */ | ||||
public function __construct() { | public function prepareForSend() { | ||||
$root = phutil_get_library_root('phabricator'); | $root = phutil_get_library_root('phabricator'); | ||||
$root = dirname($root); | $root = dirname($root); | ||||
require_once $root.'/externals/phpmailer/class.phpmailer-lite.php'; | require_once $root.'/externals/phpmailer/class.phpmailer-lite.php'; | ||||
$this->mailer = new PHPMailerLite($use_exceptions = true); | $this->mailer = new PHPMailerLite($use_exceptions = true); | ||||
$this->mailer->CharSet = 'utf-8'; | $this->mailer->CharSet = 'utf-8'; | ||||
$encoding = PhabricatorEnv::getEnvConfig('phpmailer.smtp-encoding'); | $encoding = $this->getOption('encoding'); | ||||
$this->mailer->Encoding = $encoding; | $this->mailer->Encoding = $encoding; | ||||
// By default, PHPMailerLite sends one mail per recipient. We handle | // By default, PHPMailerLite sends one mail per recipient. We handle | ||||
// combining or separating To and Cc higher in the stack, so tell it to | // combining or separating To and Cc higher in the stack, so tell it to | ||||
// send mail exactly like we ask. | // send mail exactly like we ask. | ||||
$this->mailer->SingleTo = false; | $this->mailer->SingleTo = false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |
Should this be phpmailerlite.smtp-encoding?