Tuesday, April 5, 2011

Rewriting the Envelope "From" Address

I use AuthSMTP for mail delivery when sending automated emails via my web server. Recently, I noticed that they were failing:

Real domain name required for sender address (in reply to MAIL FROM command)
The web server was using www-data@localhost as the envelope "from" address and AuthSMTP didn't like such a bogus domain.

While reading/searching the postfix documentation, I discovered that postfix can rewrite such local/bogus email addresses automagically. See the section on Generic mapping for outgoing SMTP mail.

But postfix died after I customized the example and tried to restart postfix. The example forgot to mention that the mapping needs to be encoded in a database format in order for postfix to read it. After you create a file named generic in /etc/postfix, you need to run:

sudo postmap hash:generic
from the /etc/postfix directory. This will create a Berkeley DB file with the same information as your plain-text file.

No comments:

Post a Comment