Jul 23 03:36:25 postfix/pickup: xxx: uid=1000 from=<ubuntu>
Jul 23 03:36:25 postfix/cleanup: xxx: message-id=<20130723033625.xxx@damA-21-13.compute-7.internal>
Jul 23 03:36:25 postfix/qmgr: xxx: from=<ubuntu@damA-21-13.compute-7.internal>, size=506, nrcpt=1 (queue active)
Jul 23 03:36:25 postfix/smtp: xxx: to=<email@example.com>, relay=email-smtp.us-east-1.amazonaws.com[10.20.30.40]:25, delay=0.31, delays=0.07/0.04/0.1/0.1, dsn=5.0.0, <b>status=bounced</b> (host email-smtp.us-east-1.amazonaws.com[10.20.30.40] said: <b>554 Message rejected: Email address is not verified.</b> (in reply to end of DATA command))
On many Unix systems your mail log is located at /var/log/mail.log
You are confused because you did verify the sender's email in the Amazon AWS Console, which in this case is firstname.lastname@example.org. You don't understand why the log says From address is some bogus email like ubuntu@damA-21-13.compute-7.internal instead.
Your PHP code looks like the following.
<?php $to = 'email@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: firstname.lastname@example.org' . "\r\n" . 'Reply-To: email@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?>Looks good doesn't it? You set the From header explicitly to firstname.lastname@example.org but for some reason Amazon SES SMTP interface keeps ignoring the address you set in the From header.
It seems you cannot control the From field of your outgoing email and Amazon SES SMTP interface always complains the From email, ubuntu@damA-21-13.compute-7.internal, is not verified and bounces your email.
In fact before you followed Amazon's official instructions on Integrating Amazon SES with Postfix you could send emails fine and you could set the From header successfully, just not reliably.
The whole point of using Amazon SES is to send emails reliably so that the emails you send do NOT end up in recipients' spam boxes.
How do you fix the error 554 Message rejected: Email address is not verified and avoid your email being bounced again? How do you fix the error that your email's From header is being ignored in PHP mail() function?
The problem is you need to include Return-Path header and you need to add a flag in PHP mail() function like the following.
<?php $to = 'email@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: firstname.lastname@example.org' . "\r\n" . 'Return-Path: email@example.com' . "\r\n" . 'Reply-To: firstname.lastname@example.org' . "\r\n"; mail($to, $subject, $message, $headers, '-f email@example.com'); ?>After you made the changes restart Postfix by running the following command.
sudo /etc/init.d/postfix restart
Your email should be sent successfully! In the email log you should see the following entries.
Jul 23 06:07:31 postfix/pickup: xxx: uid=1000 from=
Jul 23 06:07:31 postfix/cleanup: xxx: message-id=<20130723060731.xxx@damA-21-13.compute-7.internal>
Jul 23 06:07:31 postfix/qmgr: xxx: from=
Jul 23 06:07:31 postfix/smtp: xxx: to=
Jul 23 06:07:31 postfix/qmgr: xxx: removed
Obviously status=sent indicates the outgoing email has been successfully accepted for delivery.
It is important to note that just because the mail has been accepted for delivery, it does NOT mean the mail will actually reach the intended destination.
If you have any questions let me know and I will do my best to help you!