Simple Email Forwarding with Virtualmin

Setting up email addresses for a custom domain (ie: ) is probably the easiest thing you can do to add professionalism to your business, brand, or project. Frankly, if your business email address is I can’t take you seriously.

There are many ways to do this – most domain registrars offer this as an added, paid service (and generally grossly overcharge). However, this option comes with a few downsides:

Usually, they offer you a mailbox with a tiny amount of storage and a terrible interface, making your only reasonable option fetching the mail into a different client (gmail, thunderbird, outlook, etc) via POP3 or IMAP. This means you aren’t getting your mail in real time. Additionally, if you are using a client on your computer or phone to fetch the email directly (instead of a different provider, like gmail), you either have to leave it on their server (and run up on those ridiculously low mailbox limits) or risk only having the email on one of your many devices. Not a good solution.

Moreover, if you have LOTS of domain names, paying $7 a month for each one can add up VERY QUICKLY. I’m currently running email addresses for over 20 domains – there is no way I will pay ~$150/month just to get my email addresses.

Take heart, there is a better way! Setting up your own email server is a snap, assuming you already have a server box running somewhere (if not, maybe it is time to go get one!). I use virtualmin to manage all my servers, so getting procmail and postfix set up is literally done for me. If you are hosting your own site, this process should be just one of the steps in setting that up. However, if you already have a site hosted elsewhere, you can still use virtualmin for your email addresses.

Before you start, you need to decide if you want a mailbox on the server (holds all your mail, you can fetch it using POP3/IMAP or read it on server using various mail tools) or if you just want to forward incoming mail to another address (or both!). For my small projects, I generally forward the email on to my regular gmail account instead of storing the mail on the server. This lets me get my email in real time AND take advantage of gmail’s excellent spam filtering. NOTE: if you do this, you MUST tell procmail to NOT modify the message container at all (or add SPAM to the subject line), or gmail will decide YOU are the one sending all that spam and block everything coming from your server. YOU DO NOT WANT THIS. Read this for more details.

The first action you need to take is adding a virtual server for your new domain. Add your domain name and hit create. When virtualmin is finished setting up your server, click ‘Return to Virtual Server Details’.

Virtualmin - Create New Virtual Server

Virtualmin - Virtual Server Created

Scroll down a bit then click the button for ‘Edit Mail Aliases’ (click ‘Edit Users’ if you want to set up a mailbox on the server instead of just forwarding). On the following page, click the link for ‘Add an alias to this domain’.

Virtualmin - Add Mail Alias

Now, add whatever you want the email address to be to the ‘Name’ field (the yourname part of If you already are using a mailbox on the server you can check the ‘Deliver Locally?’ box and add the mailbox name. Check the ‘Forward to other address’ box and enter the email address where you want this mail to go. There are lots of other options you can use here, like setting up automatic replies or bouncing the mail. Hit ‘Create’ when you’re finished and the server will be set up!

Virtualmin - Creating Mail Alias

Now, if you email that address, NOTHING WILL HAPPEN. What? This is because the internet doesn’t magically know that your server is ready to process mail for your domain. To finish this setup, you need to go to your domain registrar and point your MX records at your server. Get your server IP (mine are on Amazon, so I grab the public IP from the AWS console) and put it in a new A record (mine is named mail), then add an MX record pointing to that ( This will send emails on to your email server without changing your website hosting.

DNS Settings - A and MX Records

Wait for the changes to propagate across the internet, then send yourself a test email. See, wasn’t that easy?

Leave a Comment