From e4049e879764b7ffde827ca58b2255d1e2880b5a Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 12 Aug 2014 12:27:13 -0700 Subject: [PATCH] Fix verbose email addresses being passed to mail adapters Summary: Fixes T5233. - The mail adapter API currently expects plain addresses (like `a@b.com`) in `addTos()`, and some adapters can not accept fancy verbose addresses (like `"name" `). - When we try to send error email, we pass the entire "From" header into the API. This is incorrect. - Since it would be nice to make this just work in the future, fix it inside the API. - Specifically, this is reached with: send email -> generates error -> we try to send you an email back -> we send it to your "From" -> some mailers choke on the fancy name if you have one. Test Plan: Processed an errorneous email with a fancy "From", got a response error. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5233 Differential Revision: https://secure.phabricator.com/D10232 --- .../metamta/storage/PhabricatorMetaMTAMail.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index e5445b0abf..e583e508b5 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -96,6 +96,15 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { } public function addRawTos(array $raw_email) { + + // Strip addresses down to bare emails, since the MailAdapter API currently + // requires we pass it just the address (like `alincoln@logcabin.org`), not + // a full string like `"Abraham Lincoln" `. + foreach ($raw_email as $key => $email) { + $object = new PhutilEmailAddress($email); + $raw_email[$key] = $object->getAddress(); + } + $this->setParam('raw-to', $raw_email); return $this; }