Goodness am I grateful for a response on this. It's been rough going. It's hard to find help on postfix configuration.
I've seen Mandrill before. Finding a mail delivery service is not my primary problem. Amazon SES is designed to accomplish the same purpose as Mandrill, doesn't require me to create a yet another account, and is likely to enjoy low latency connections to EC2 services. The problem I have is rather one of how to configure the sending of mail on my server (the MTA???). After yet another long stretch of trial-and-error, I have managed to configure postfix so that
a) local mail delivery appears to be entirely disabled
b) email with a local address (e.g., root, root@localhost, etc) gets changed into a particular domain (e.g., root@example.com)
c) all mail is delivered by making a TLS connection to an SMTP gateway of Amazon SES
This feels like a triumph and yet I still have one problem. Amazon SES requires mail senders to be "verified" which involves clicking a link in an email sent to a particular email address. Because I have bothered to verify user1@example.com, Amazon SES works brilliantly when I login to my server via ssh as user1 and send a mail message using these commands:
user1@domain:~$ sendmail -t
To: somerone@gmail.com
Subject: Test Email
sent via SES!
.
If, however, I login as user2 on my server and try the same above, Amazon SES bounces the mail because I have not yet bothered to verify user2@example.com:
Amazon SES SMTP Gateway wrote: status=bounced (host email-smtp.us-east-1.amazonaws.com[23.23.156.241] said: 554 Message rejected: Email address is not verified. (in reply to end of DATA command))
One of today's sobering realizations is that I don't really understand the relationship between postfix and sendmail. I understand (perhaps incorrectly) that postfix is a more modern replacement for the original sendmail MTA but the fact that a sendmail command exists on my server (probably postfix mimicking sendmail) and the many references to sendmail when folks talk about PHP mail sort of muddies the waters for me.
The issue I am trying to solve today is how to avoid having to "verify" every single sender of mail -- users and various processes like fail2ban or cron jobs, etc. -- that might want to send mail from this server. It is my intention to make a machine image of this server that I can use whenever I need to create a new website or bring a server online for some reason. Verifying a bunch of new addresses every time sounds like a pain. I'm wondering:
1) What aspect of a given email message is examined by the Amazon SES gateway to determine the "sender"? Is it one of the commands issued during the SMTP session? A mail header?
2) Is it possible to configure postfix to make all outgoing mail have one single sender such that Amazon SES accepts the outgoing mail for delivery?
3) If there's not some magic postfix trick, I will have to attempt to visit each mail-sending process and alter their configuration -- are these processes going to be configurable such that this problem can be fixed?
4) Might I be able to establish some envelope sender that solves this problem?
I'm not sure what this means, but I was able to send email through the gateway with sendmail while logged in as user2 by specifying user1 as sender with the -f flag:
user2@domain:/home/user2$ sendmail -tf user1@example.com
If anyone could provide advice or suggestions about how I might get to the bottom of this, I'd be most grateful.