12

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 dsadaerwer.lala-band-sucks.justin-is-a-beaver@gmail.com I receive:

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

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

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)

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 bounce@simulator.amazonses.com, 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.

Victor Dodon
  • 1,617
  • 2
  • 18
  • 27
  • 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ó Nov 12 '15 at 11:33
  • I am also having this problem - did you find a fix? – niico Mar 29 '16 at 23:41

1 Answers1

1

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)
Maria Vilaró
  • 304
  • 2
  • 11