未收到Amazon SES退回通知

Vic*_*don 12 ubuntu-server amazon-web-services amazon-sns amazon-ses

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

gmail.com          smtp:email-smtp.eu-west-1.amazonaws.com:25
*                  :
Run Code Online (Sandbox Code Playgroud)

此外,我在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
Run Code Online (Sandbox Code Playgroud)

但是如果从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)
Run Code Online (Sandbox Code Playgroud)

因此,亚马逊SES接受邮件,但我没有收到有关失败的通知.有什么不对?

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

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

Mar*_*aró 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 = '';
Run Code Online (Sandbox Code Playgroud)

我将其设置为与 $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()
Run Code Online (Sandbox Code Playgroud)

如果您在 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)
Run Code Online (Sandbox Code Playgroud)