Is there any way to perform SRS, or something similar using Postfix?
When I get a mail from [email protected], I forward it (via a catchall) to [email protected], but GMail is checking SPF, and seeing that my server is not authorized to send mail on behalf of example.org. I'd like to rewrite the sender to something@myserver, while leaving the from as [email protected].
Here are the steps to install postsrsd from Timo Röhling. These instructions seem to work for many Unix flavors including Ubuntu 14.04.
There's a 2012 tutorial here on setting up SRS with Postfix on Debian: http://blog.phusion.nl/2012/09/10/mail-in-2012-from-an-admins-perspective/
Here's a 2013 tutorial for Ubuntu: http://www.ameir.net/blog/archives/71-installing-srs-extensions-on-postfix-ubuntudebian.html
Here are some thoughts, which will require some customization to meet your exact needs. The first thing I found was that Postfix doesn't seem to like doing anything to addresses that are aliases (i.e.
virtual_alias_domain
/virtual_alias_maps
). But that's fine since in reality it doesn't matter what these addresses are called as long as everything gets delivered properly in the end.So, in Postfix's
main.cf
, add the following lines:Next, you need to tell Postfix what
munger
actually means. Add the following (see pipe(8) for more options). So add the following tomaster.cf
:According to the above, anything destined for
example.org
will get sent to the/usr/bin/redirector
program (or whatever you want to call it). For most normal things, you'd need some command line arguments for sender/recipient information (again,pipe(8)
has more details) but since the sender and destination addresses are fixed, nothing else is needed on the command line.Now you just need to write the
redirector
program. This worked for me:It's a regular shell script (or your language of choice) so make it as simple or complex as you like.
You would better forget the whole spf thing and use dkim instead.
Here is a good article describing SPF problems.