1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-03 11:21:01 +01:00

Spoof usernames with Amazon SES

Summary:
When I tested this earlier I was incorrectly interpreting PHPMailer errors as
SES errors. This works fine as long as you get around the peculiarities of
PHPMailer.

Test Plan:
Sent email to myself, received email from a human-readable address in my mail
client.

Reviewed By: rm
Reviewers: rm, tuomaspelkonen, jungejason, aran
CC: aran, rm, epriestley
Differential Revision: 246
This commit is contained in:
epriestley 2011-05-06 16:35:59 -07:00
parent 80698aba6f
commit a64d5177a7
5 changed files with 31 additions and 13 deletions

View file

@ -2,6 +2,10 @@ This is not a complete list of changes, just of API or workflow changes that may
break existing installs. Newer changes are listed at the top. If you pull new
changes and things stop working, check here first!
May 10 2011 - PhabricatorMailImplementationAdapter
The signatures of setFrom() and addReplyTo() have changed, and they now
accept a second "$name = ''" parameter. This represents a human-readable
name component of the address.
May 9 2011 - git submodule
As of commit 2a39fd0, you must run "git submodule update --init" in your

View file

@ -18,8 +18,8 @@
abstract class PhabricatorMailImplementationAdapter {
abstract public function setFrom($email);
abstract public function addReplyTo($email);
abstract public function setFrom($email, $name = '');
abstract public function addReplyTo($email, $name = '');
abstract public function addTos(array $emails);
abstract public function addCCs(array $emails);
abstract public function addHeader($header_name, $header_value);

View file

@ -30,13 +30,13 @@ class PhabricatorMailImplementationPHPMailerLiteAdapter
return true;
}
public function setFrom($email) {
$this->mailer->SetFrom($email, '', $crazy_side_effects = false);
public function setFrom($email, $name = '') {
$this->mailer->SetFrom($email, $name, $crazy_side_effects = false);
return $this;
}
public function addReplyTo($email) {
$this->mailer->AddReplyTo($email);
public function addReplyTo($email, $name = '') {
$this->mailer->AddReplyTo($email, $name);
return $this;
}

View file

@ -30,13 +30,20 @@ class PhabricatorMailImplementationTestAdapter
$this->config = $config;
}
public function setFrom($email) {
public function setFrom($email, $name = '') {
$this->guts['from'] = $email;
$this->guts['from-name'] = $name;
return $this;
}
public function addReplyTo($email) {
$this->guts['reply-to'] = $email;
public function addReplyTo($email, $name = '') {
if (empty($this->guts['reply-to'])) {
$this->guts['reply-to'] = array();
}
$this->guts['reply-to'][] = array(
'email' => $email,
'name' => $name,
);
return $this;
}

View file

@ -213,23 +213,30 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
$mailer->setFrom($default);
} else if (!PhabricatorEnv::getEnvConfig('metamta.can-send-as-user')) {
$from = $params['from'];
$handle = $handles[$from];
if (empty($params['reply-to'])) {
$params['reply-to'] = $handles[$from]->getEmail();
$params['reply-to'] = $handle->getEmail();
$params['reply-to-name'] = $handle->getFullName();
}
$mailer->setFrom($default);
$mailer->setFrom(
$default,
$handle->getFullName());
unset($params['from']);
}
$is_first = !empty($params['is-first-message']);
unset($params['is-first-message']);
$reply_to_name = idx($params, 'reply-to-name', '');
unset($params['reply-to-name']);
foreach ($params as $key => $value) {
switch ($key) {
case 'from':
$mailer->setFrom($handles[$value]->getEmail());
break;
case 'reply-to':
$mailer->addReplyTo($value);
$mailer->addReplyTo($value, $reply_to_name);
break;
case 'to':
$emails = array();