modern days aliases
Asuming we have on a mail server(that hosts domain1.com) some external aliases, like email@example.com has an alias for firstname.lastname@example.org, which is hosted on a different server, probably on a different mail provider. Typically when a mail is sent to email@example.com, it’s sender’s mail server sends the mail to the MX which hosts domain1.com the mail is accepted, but being an alias the domain1.com MX tries to send it again to firstname.lastname@example.org.
This didn’t used to be a problem few years back when methods like SPF or Sender-ID didn’t existed and the server hosting the domain2.com email would not check if the server identifying as the original sender’s mail server is legit or not.
Sadly, nowadays this wouldn’t work, the domain2.com MX would reject the mail just because the domain1.com MX is not the MX for the original sender.
So, the domain1.com mail server needs to alter this email so that domain2.com’s MX believes the mail comes from email@example.com.
In Postfix this type of configuration is quite simple. The first thing to set the virtual_alias_maps table and put into it firstname.lastname@example.org as an alias to a local account, something like
The next step is to modify the local alias map, typically situated in the file /etc/aliases and put something like:
user1: "|/opt/redirector email@example.com firstname.lastname@example.org"
Then we need to create the /opt/redirector script, which has only two lines:
#!/bin/sh /usr/sbin/sendmail -bm -f $1 $2
the script needs to be executed
chmod +x /opt/redirector
some database update
restart postfix(probably not really necessary) and voila!