As mentioned previously, I went with a barebones roll-your-own approach to setting up this server. One of the things that slipped my mind initially was mail forwarding. My former cPanel site made setting up things like mail forwarding a matter of a few clicks. Instead, I got to play with DNS and Postfix1 this morning.
Here is what I ended up doing:
Modified my DNS records
When I set up my original DNS, I only did the bare minimum, pointing my raw domain at my IP address. Now, I added a couple of CNAME records,
www.brianmajewski.com. 1800 IN CNAME brianmajewski.com. mail.brianmajewski.com. 1800 IN CNAME brianmajewski.com. brianmajewski.com. 1800 IN MX 1 mail.brianmajewski.com.
Took a shower while the DNS propagated.
Now, with my server listening for incoming mail, I had to send it somewhere. I wanted to forward all mail to this domain to a catch-all address I have with gmail. So, first, ensure that Postfix is installed, with
dpkg -s postfixand if not, install it with
apt-get install postfix
Now we want to tell Postfix about our virtual domain. I added the following lines to
virtual_alias_domains = brianmajewski.com virtual_alias_maps = hash:/etc/postfix/virtual
- And then I created the mapping rules in
/etc/postfix/virtual. You can do individual mapping of addresses, but for me, the catch-all is more useful.
- Time to reload Postfix.
postmap /etc/postfix/virtual /etc/init.d/postfix reload
- And finally I fired off an email to firstname.lastname@example.org and basked in the glory of success.
And all of this before 8:30am on a Sunday morning...
1. I use the word play loosely. I used to regularly do work like this, had the O'Reily book and everything, but it's amazing what one forgets over a couple decades.↩