13
votes

I have configured postfix on my server to deliver only @gmail.com mails to Amazon SES:

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

Also, I configured in the Amazon SES console to receive Bounces and Complains on mail using Amazon SNS. The problem is that I don't receive a bounce if I send a mail to a non-existent gmail address.

If sending a mail from mail.google.com to the address [email protected] I receive:

Delivery to the following recipient failed permanently:
 [email protected]

But If sending from a PHP script to the same address, postfix says:

E4E1A9F9CE: to=<[email protected]>, 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)

So Amazon SES accepts the mail but I don't get notified of the failure. What can be wrong?

Note. When sending to valid emails, everything works as expected.

Also, when sending a test mail from AWS SES console to [email protected], I am immediately notified via email, but sending to the same email from a PHP script via email-smtp.eu-west-1.amazonaws.com does not results in an email notification.

1
Hi, you asked this more than a year and a half ago... did you find the solution? I am facing the same problem now, I don't receive bounce or complaint notifications.Maria Vilaró
I am also having this problem - did you find a fix?niico

1 Answers

1
votes

I was facing the same problem. In my case, I'm using the PHPMailer library (https://github.com/PHPMailer/PHPMailer/) and I solved it by specifying a Sender of the message.

/**
 * 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 = '';

I setted it to the same address as the $From and I now receive the bounces in the expected address.

So this is my working code:

$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()

If you use the setFrom method in PHPMailer, it will also set automatically the Sender to the same address.

/**
 * 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)