Hosting your own mail server is finally easy! Here I hope to provide an in-depth guide showing you how to set up your own server which won’t get you or your clients blacklisted!
Buying a domain
You’re going to want a cool email address like [email protected] – so head over to Namecheap and purchase a domain for as little as $1 for a .xyz
Get yourself a server!
Ramnode is one of my favourite server hosts due to the amazing support, sometimes they’ve replied to my requests instantly, and they’re always very fast to deliver servers, I assume you want to do this now so head on over to Ramnode and get a server for as little as $15 a year, not bad seeing as you’ve got email for a year for $16 and unlimited users, eh?
Install Your Server and VestaPanel
Now you’ll want to configure your server – if you have purchased a server with under 4096MB of RAM, you’ll want to install a 32 bit version of Debian, use Debian because it plays nicely with Vesta.
Once you have your VPS up and running, login via ssh with root password Ramnode gave you.
Seeing that we have a new VPS running, go ahead and refresh the package indexes:
Now may also be a good time to upgrade any packages that might need it:
Next, we download the Vesta installation script:
curl -O http://vestacp.com/pub/vst-install.sh
After which we run this script:
The install script shows us some information on the software that will be installed:
Press “y” and “enter” to proceed with the installation.
Then enter a valid email address you have access to
Upon completion, you will be presented with the following information:
Take note of the address, username, and password. You will need these to log in to the control panel.
Log in to Vesta
Now that Vesta is installed, open your browser and go to the address that Vesta gave you in step two. If you didn’t take note of it, the address will be as follows:
*Make sure to use HTTPS, you will be presented with a prompt to confirm visiting your site without a valid SSL certificate, click Continue in Safari or Advanced > Proceed in Chrome
Set Up Your DNS
Head back over to Namecheap and log in to your DNS management panel, then select ‘All Host Records’
Add an A record pointing to your new server with the hostname ‘mail’ where the IP address is that of your new Ramnode VPS.
Then ensure that your Mail settings are like so:
And save your changes, you will then see the following section:
Configure the mail server hostname to the one you just set up i.e ‘mail.yourdomain.com’ three times with the three different MX preferences – this ensures all providers’ emails will reach you!
Set up your email account
Log back into your VestaCP instance and select mail, then add a new domain (drop the mail. part – or the subdomain) and make sure to select DKIM support. Then add an account. You can then either open webmail and receive emails or set up your mail client using mail.yourdomain.com as the IMAP and SMTP server and [email protected] + password as the username/password.
Congratulations! You can receive mail!
But! you can’t send mail without being classed as spam just yet. Now you need to set your reverse hostname in your ramnode VPS control panel with Ramnode’s solusVM CP. Scroll to the bottom of your server and select the ‘Hostname’ tab like so and enter the previously configured mail server hostname.
DKIM and SPF setup on your domain
Now comes the last part – we set up DKIM (DomainKeys Identified Mail) and SPF (Sender Policy Framework) so that hosts like Google Mail, Apple, and other providers don’t class our emails as spam.
Log into vestacp’s webmail with http://mail.yourdomain.com/webmail using [email protected] and your password and send a blank email to the following address:
You will then receive results from [email protected] – search for the term ‘dkim-signature’ and you should see a long string like the following:
Strip out the ‘dkim-signature:’ section, and create a TXT record in the Namecheap ‘All Host Records’ section with ‘_domainkey’ as the host and the text you created earlier without ‘dkim-signature:’ as the string.
Create a second TXT record with ‘yourdomain.com’ as the hostname and the following string as the text entry but substitute the IP address for your own server:
v=spf1 a mx ip4:126.96.36.199 ~all
There you go!
You can now send and receive emails :-)