未收到Amazon SES退回通知

时间:2014-06-26 13:57:02

标签: amazon-web-services amazon-ses ubuntu-server amazon-sns

我已在我的服务器上配置了postfix,只能将@ gmail.com邮件发送到Amazon SES:

gmail.com          smtp:email-smtp.eu-west-1.amazonaws.com:25
*                  :

此外,我在Amazon SES控制台中配置了使用Amazon SNS接收邮件上的Bounces和Complains。问题是,如果我将邮件发送到不存在的Gmail地址,我就不会收到退款。

如果从mail.google.com发送邮件到地址dsadaerwer.lala-band-sucks.justin-is-a-beaver@gmail.com,我会收到:

Delivery to the following recipient failed permanently:
 dsadaerwer.lala-band-sucks.justin-is-a-beaver@gmail.com

但是如果从PHP脚本发送到同一地址,postfix说:

E4E1A9F9CE: to=<dsadaerwer.lala-band-sucks.justin-is-a-beaver@gmail.com>, relay=email-smtp.eu-west-1.amazonaws.com[54.72.42.170]:25, delay=21, delays=0.02/0.04/11/10, dsn=2.0.0, status=sent (250 Ok 00000146d86bcc13-9fa1ac16-b1cd-476e-8398-31f406d47961-000000)

因此,亚马逊SES接受了邮件,但我没有收到有关失败的通知。什么可能是错的?

请注意。发送到有效的电子邮件时,一切都按预期工作。

此外,当从AWS SES控制台向bounce@simulator.amazonses.com发送测试邮件时,我会立即通过电子邮件通知我,但是通过email-smtp.eu-west-1从PHP脚本发送到同一封电子邮件.amazonaws.com不会产生电子邮件通知。

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。在我的例子中,我使用PHPMailer库(https://github.com/PHPMailer/PHPMailer/)并通过指定消息的发件人来解决它。

/**
 * The Sender email (Return-Path) of the message.
 * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
 * @type string
 */
public $Sender = '';

我将它设置为与$ From相同的地址,我现在收到预期地址的退回。

所以这是我的工作代码:

$this->mail = new PHPMailer();
$this->mail->CharSet = 'utf-8';
$this->mail->From = $from_address;
$this->mail->Sender = $from_address;
$this->mail->FromName = $from_name;
$this->mail->Subject = $subject;
$this->mail->Body    = $body;
$this->mail->AltBody = $altBody;
$this->mail->addAddress($to_address, $to_name);
$this->mail->send()

如果您在PHPMailer中使用setFrom方法,它还会自动将发件人设置为相同的地址。

/**
 * Set the From and FromName properties.
 * @param string $address
 * @param string $name
 * @param boolean $auto Whether to also set the Sender address, defaults to true
 * @throws phpmailerException
 * @return boolean
 */
public function setFrom($address, $name = '', $auto = true)