Fix EncodeQ implementation in PHPMailer, and provide SSL/TLS options
Summary:
See f5c2a2ab4b (commitcomment-2333247)
Copy of working implementation from PHPMailerLite.
Also expose the SSL/TLS options.
Test Plan: Switched to this mailer, configured Gmail SMTP, sent email. Verified email arrived intact.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran, mbeck
Differential Revision: https://secure.phabricator.com/D4239
This commit is contained in:
28
externals/phpmailer/class.phpmailer.php
vendored
28
externals/phpmailer/class.phpmailer.php
vendored
@@ -1710,6 +1710,13 @@ class PHPMailer {
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: Phabricator patch to remove use of "/e". See D2147.
|
||||
*/
|
||||
private function encodeQCallback(array $matches) {
|
||||
return '='.sprintf('%02X', ord($matches[1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode string to q encoding.
|
||||
* @link http://tools.ietf.org/html/rfc2047
|
||||
@@ -1719,21 +1726,32 @@ class PHPMailer {
|
||||
* @return string
|
||||
*/
|
||||
public function EncodeQ ($str, $position = 'text') {
|
||||
|
||||
// NOTE: Phabricator patch to remove use of "/e". See D2147.
|
||||
|
||||
// There should not be any EOL in the string
|
||||
$encoded = preg_replace('/[\r\n]*/', '', $str);
|
||||
|
||||
switch (strtolower($position)) {
|
||||
case 'phrase':
|
||||
$encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/", "'='.sprintf('%02X', ord('\\1'))", $encoded);
|
||||
$encoded = preg_replace_callback(
|
||||
"/([^A-Za-z0-9!*+\/ -])/",
|
||||
array($this, 'encodeQCallback'),
|
||||
$encoded);
|
||||
break;
|
||||
case 'comment':
|
||||
$encoded = preg_replace("/([\(\)\"])/", "'='.sprintf('%02X', ord('\\1'))", $encoded);
|
||||
$encoded = preg_replace_callback(
|
||||
"/([\(\)\"])/",
|
||||
array($this, 'encodeQCallback'),
|
||||
$encoded);
|
||||
break;
|
||||
case 'text':
|
||||
default:
|
||||
// Replace every high ascii, control =, ? and _ characters
|
||||
//TODO using /e (equivalent to eval()) is probably not a good idea
|
||||
$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/',
|
||||
"'='.sprintf('%02X', ord('\\1'))", $encoded);
|
||||
$encoded = preg_replace_callback(
|
||||
'/([\000-\011\013\014\016-\037\075\077\137\177-\377])/',
|
||||
array($this, 'encodeQCallback'),
|
||||
$encoded);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user