我在服务器上配置了后缀,以仅将@ gmail.com邮件传递到Amazon SES:
gmail.com smtp:email-smtp.eu-west-1.amazonaws.com:25
* :
另外,我在Amazon SES控制台中配置为使用Amazon SNS接收邮件的退回和投诉。问题是,如果我将邮件发送到不存在的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脚本发送到相同的地址,则后缀表示:
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)
因此,Amazon SES接受邮件,但未收到有关失败的通知。有什么事吗
注意。发送到有效的电子邮件时,一切都会按预期进行。
此外,当从AWS SES控制台发送测试邮件到bounce@simulator.amazonses.com时,我会立即通过电子邮件收到通知,但会通过email-smtp.eu-west-1.amazonaws从PHP脚本发送到同一封电子邮件。 com不会产生电子邮件通知。
最佳答案
我面临着同样的问题。就我而言,我正在使用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方法,它还将自动将Sender设置为相同的地址。
/**
* 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)