How to rewrite outgoing address in postfix - From http://semi-legitimate.com/blog/item/how-to-rewrite-outgoing-address-in-postfix
Sometimes I find myself configuring an internal Linux machine to be able to send emails for alerts or from a particular application. Since this will not be a primary mail server, I just want to rewrite the outgoing address to be something that make sense with the proper domain for the users. Here are the quick steps to accomplish this:
Modify the "mydomain" variable to your email domain
mydomain = example.com
Make sure to uncomment the proper network interface. I'm usually lazy and just do all.
inet_interfaces = all
Now at the bottom of this file you need to specify the generic map file for rewriting the address.
smtp_generic_maps = hash:/etc/postfix/generic
Save and exit main.cf. Now we need to edit /etc/postfix/generic
You need to specify the mapping of the original address to the one you want. Since in this case I just want to rewrite everything I usually add the following two lines and it seems to catch everything.
firstname.lastname@example.org email@example.com @example.com firstname.lastname@example.org
Save and exit the file. Now we need to create the postfix db.
This will create the /etc/postfix/generic.db hash file. Now just restart postfix and test.
EDIT: umm..so I was doing this on an old version of Red Hat/Postfix 2.0 and my own directions didn't work. (embarrassing...) Turns out you have to use a different file. Instead of using smtp_generic_maps, use sender_canonical_maps like so:
sender_canonical_maps = hash:/etc/postfix/canonical
Then /etc/postfix/canonical is setup just like the generic file example above. Use the
Restart postfix and test.