We have a web app that sends email. Right now, if we send an email, and it is bounced (for whatever reason), no one knows since it comes from a no-reply address, which is never checked for bounces.
Some of these emails are very important, and we'd like to show the failed email attempt in the interface.
My thought is to do this:
- Inject an X-Header: guid-goes-here into the email to uniquely identify it.
- Create a milter in Postfix that will run the email through a script to parse out that header and (hopefully) at the same time capture the queue ID.
- Parse mail.log for that queue ID and get its disposition (250 OK).
For #2, when I create a milter, does postfix inject the queue ID when it pipes the mail to the script? I am in the early stages of this, and haven't gotten it to work yet. Also, I have chosen to use SMTP content filter in post-queue (http://www.postfix.org/FILTER_README.html). Is this the correct choice?
Simply use an address as the envelope sender that is actually monitored.
Do it like this:
As you can see, the initial recipient (recipient@recipientdomain) is encoded into the sender address you're using. If the mail bounces, it bounces back to bounces+recipient=recipientdomain@$yourdomain -- so with no parsing at all you can find out what address bounced!
That's called VERP and is used by mailing list managers like ezmlm or mailman: https://en.wikipedia.org/wiki/Variable_envelope_return_path
Your proposed approach is flawed, since the "250 OK" status doesn't really indicate that the mail won't be bounced by subsequent relays!