@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix EncodeQ implementation in PHPMailer, and provide SSL/TLS options

Summary:
See https://github.com/facebook/phabricator/commit/f5c2a2ab4bbe6317993fbcb406a86993e6ab75e0#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

+39 -11
+11 -6
conf/default.conf.php
··· 291 291 // mostly never arrive. 292 292 'metamta.can-send-as-user' => false, 293 293 294 - 295 294 // Adapter class to use to transmit mail to the MTA. The default uses 296 295 // PHPMailerLite, which will invoke "sendmail". This is appropriate 297 296 // if sendmail actually works on your host, but if you haven't configured mail 298 - // it may not be so great. You can also use Amazon SES, by changing this to 299 - // 'PhabricatorMailImplementationAmazonSESAdapter', signing up for SES, and 300 - // filling in your 'amazon-ses.access-key' and 'amazon-ses.secret-key' below. 297 + // it may not be so great. A number of other mailers are available (e.g., SES, 298 + // SendGrid, SMTP, custom mailers), consult "Configuring Outbound Email" in 299 + // the documentation for details. 301 300 'metamta.mail-adapter' => 302 301 'PhabricatorMailImplementationPHPMailerLiteAdapter', 303 302 ··· 317 316 'metamta.user-address-format' => 'full', 318 317 319 318 // If you're using PHPMailer to send email, provide the mailer and options 320 - // here. PHPMailer is a superior to PHPMailerLite and provides more mailers. 321 - // You need it when you want to use SMTP instead of sendmail as the mailer. 319 + // here. PHPMailer is much more enormous than PHPMailerLite, and provides more 320 + // mailers and greater enormity. You need it when you want to use SMTP 321 + // instead of sendmail as the mailer. 322 322 'phpmailer.mailer' => 'smtp', 323 323 'phpmailer.smtp-host' => '', 324 324 'phpmailer.smtp-port' => 25, 325 + 326 + // When using PHPMailer with SMTP, you can set this to one of "tls" or "ssl" 327 + // to use TLS or SSL. Leave it blank for vanilla SMTP. If you're sending 328 + // via Gmail, set it to "ssl". 329 + 'phpmailer.smtp-protocol' => '', 325 330 326 331 // Set following if your smtp server requires authentication. 327 332 'phpmailer.smtp-user' => null,
+23 -5
externals/phpmailer/class.phpmailer.php
··· 1711 1711 } 1712 1712 1713 1713 /** 1714 + * NOTE: Phabricator patch to remove use of "/e". See D2147. 1715 + */ 1716 + private function encodeQCallback(array $matches) { 1717 + return '='.sprintf('%02X', ord($matches[1])); 1718 + } 1719 + 1720 + /** 1714 1721 * Encode string to q encoding. 1715 1722 * @link http://tools.ietf.org/html/rfc2047 1716 1723 * @param string $str the text to encode ··· 1719 1726 * @return string 1720 1727 */ 1721 1728 public function EncodeQ ($str, $position = 'text') { 1729 + 1730 + // NOTE: Phabricator patch to remove use of "/e". See D2147. 1731 + 1722 1732 // There should not be any EOL in the string 1723 1733 $encoded = preg_replace('/[\r\n]*/', '', $str); 1724 1734 1725 1735 switch (strtolower($position)) { 1726 1736 case 'phrase': 1727 - $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/", "'='.sprintf('%02X', ord('\\1'))", $encoded); 1737 + $encoded = preg_replace_callback( 1738 + "/([^A-Za-z0-9!*+\/ -])/", 1739 + array($this, 'encodeQCallback'), 1740 + $encoded); 1728 1741 break; 1729 1742 case 'comment': 1730 - $encoded = preg_replace("/([\(\)\"])/", "'='.sprintf('%02X', ord('\\1'))", $encoded); 1743 + $encoded = preg_replace_callback( 1744 + "/([\(\)\"])/", 1745 + array($this, 'encodeQCallback'), 1746 + $encoded); 1747 + break; 1731 1748 case 'text': 1732 1749 default: 1733 1750 // Replace every high ascii, control =, ? and _ characters 1734 - //TODO using /e (equivalent to eval()) is probably not a good idea 1735 - $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/', 1736 - "'='.sprintf('%02X', ord('\\1'))", $encoded); 1751 + $encoded = preg_replace_callback( 1752 + '/([\000-\011\013\014\016-\037\075\077\137\177-\377])/', 1753 + array($this, 'encodeQCallback'), 1754 + $encoded); 1737 1755 break; 1738 1756 } 1739 1757
+5
src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerAdapter.php
··· 30 30 $this->mailer->Password = 31 31 PhabricatorEnv::getEnvConfig('phpmailer.smtp-password'); 32 32 } 33 + 34 + $protocol = PhabricatorEnv::getEnvConfig('phpmailer.smtp-protocol'); 35 + if ($protocol) { 36 + $this->mailer->SMTPSecure = $protocol; 37 + } 33 38 } else if ($mailer == 'sendmail') { 34 39 $this->mailer->IsSendmail(); 35 40 } else {