我在服务器上配置了后缀,只发送@gmail.com邮件到Amazon SES:
gmail.com smtp:email-smtp.eu-west-1.amazonaws.com:25
* :
另外,我在Amazon SES控制台中配置了使用Amazon SNS接收邮件的bounce和complain。问题是,如果我向一个不存在的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时,我立即收到电子邮件通知,但从PHP脚本通过email-smtp.eu-west1.amazonaws.com发送相同的电子邮件不会产生电子邮件通知。
我也面临着同样的问题。在我的情况下,我使用PHPMailer库(https://github.com/PHPMailer/PHPMailer/),我通过指定消息的Sender来解决它。
/**
* 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)