I recently acquired a new domain name, cduan.com, and I wanted all the emails to that domain forwarded to one user account on my machine. I also wanted to be able to reply to those forwarded emails using the address the email was originally sent to. So, for example, an email to email@example.com would be delivered to my personal account, and if I sent a reply, it would come from firstname.lastname@example.org.
Receiving Mail with Postfix
- Add the following lines to /etc/postfix/main.cf:
virtual_alias_domains = cduan.com
virtual_alias_maps = hash:/etc/postfix/virtual
This tells Postfix to treat @cduan.com as a “virtual domain” and apply the alias map located at /etc/postfix/virtual.
- Create a file /etc/postfix/virtual, containing only the line “@cduan.com cduan”. This means that Postfix will rewrite the recipient (To:) address for every email to @cduan.com, delivering it to the user cduan.
- Run postmap /etc/postfix/virtual; /etc/init.d/postfix reload
Replying to Mail with Alpine
Generally Alpine (or Pine) will use its default email address for replying. To use the original @cduan.com address as the sender in replying, I did the following:
- Turn on the feature “Copy To Address to From if it is Us,” under Reply Preferences.
- Set the “Alternate Addresses” value to “.*@cduan\.com$”. This way, Alpine knows that all @cduan.com mail is actually addressed to me, so that it will copy the address as requested in step 1.