Receiving Emails for an Entire Domain with One Address
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 exampledontsendmespam@cduan.com would be delivered to my personal account, and if I sent a reply, it would come from exampledontsendmespam@cduan.com.
Here is how I did it with the mail server Postfix and my email client, Alpine.
Receiving Mail with Postfix
Postfix has a virtual domain hosting feature that makes forwarding emails to a domain simple. Following the directions in this section, I did the following:- 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.