Setting up your own email server with a VPS (virtual private server) can be tricky if you don’t know what you’re doing. Trust me when I say you are not the only one dealing with this problem. I get asked to help troubleshoot email servers all the time because they are configured incorrectly, and it’s usually just a simple step in the setup process that was overlooked.
A self-hosted email server gives business owners complete control over its operation. It is the ideal solution for people who want to upgrade from their third-party mail server and gain more flexibility and overall control.
This led me to create a simple 7-step guide that covers everything in the setup process. This guide will help you ensure that your email server runs smoothly. Let’s jump right in!
Step 1: Choosing the right VPS provider:
The first step is choosing the right VPS provider. The options I recommend that work best for setting up your own email server are Hostinger, HostGator, and Bluehost.
I’ve put together a table that compares the three of them so you can make the right choice.
| Feature | Hostinger | HostGator | Bluehost |
| Starting Price | $2.99/month | $2.75/month | $2.95/month |
| Storage | 50 GB SSD (Basic Plan) | Unmetered (basic plan) | 50 GB SSD (Basic Plan) |
| Ease of use | Custom hPanel | cPanel | cPanel |
| Customer Support | 24/7 live chat | 24/7 live chat | 24/7 live chat |
| Data Centers | Globally distributed(US, Europe, Asia) | US, Brazil, India, Singapore | Primarily US Based |
| Uptime Guarantee | 99.9% | 99.9% | 99.9% |
| Free Domain | Yes (1 year) | Yes (1 year) | Yes (1 year) |
| SSL certificate | Included | Included | Included |
| Email Hosting | Free (Basic) | Partially free. Requires setup | Free (Basic) |
| Scalability | Easy to upgrade | Very scalable | Flexible VPS options |
They are all pretty similar in pricing and features. Hostinger has the best support out of the 3 options and has the most widespread data centers, making it the best choice, in my personal opinion. It is definitely worth doing your own research and checking all 3 out.
Step 2: Register a domain name:
If you already registered a domain name, you can skip this step and proceed to install your email server software.
If you still need to register your domain name, I recommend using your VPS provider as your domain registrar since most plans come with a free domain name. If your plan doesn’t come with one, our personal recommendation is Squarespace domains.
Keep in mind that the domain you use will be the second half of your email, which will look something like “[email protected].”

Step 3: Install email server software:
Now, you will need to access your VPS with SSH and update the system packages. You will then need to choose an email server software. For this guide, I recommend Postfix, but I have also listed some other good alternatives.
- Postfix: An open-source and widely used platform for email servers. Setting up postfix for email delivery is extremely easy, and there are tons of tutorials online.
- Dovecot: An open-source platform with a strong focus on IMAP and POP3.
- Exim: Another open-source option with strong security features. This is the 2nd best choice if Postfix doesn’t seem like a good fit for you.
- Mail-in-a-Box: A platform known for being user-friendly with a pre-configured email server. It is yet another open-source platform.
Once you have chosen email server software, you can install it using the package manager. Open your terminal and update your package list. Then, use the appropriate command for your package manager (like “apt” on Debian/Ubuntu or “yum” on Red Hat/CentOS) to install the desired email server package, typically specifying “postfix” or “exim,” depending on your preference.
It’s important to remember to configure the email server settings after installation to properly set up your domain and user accounts.
Step 4: Configuring DNS records for your domain:
Log into your domain registrar. Go to domains, and then “DNS settings” for the domain you want to use for your emails.
You will need to add an MX (Mail Exchanger) record that points to your email server’s IP address. Then, you will create an A record for your server hostname. This will also be pointed to your email server’s IP address.
I recommend that you add SPF (Send Policy Framework) and DKIM (Domain-based Message Authentification) records as well. These aren’t required but will significantly help with the delivery rate of your emails since they reduce the chances of email spoofing and phishing. It’s an added layer of security that can help build trust with 3rd party software.
Once you have added all the records, you can validate them with dnschecker.org. A free tool that lets you see how your DNS changes have propagated and lets you double-check if they are properly configured. DNS changes can take 24-72 hours to propagate completely, but it usually happens within minutes.
Important record types for mailing
- MX record: Points your domain to the email server
- A record: Links your domain to the VPS IP address
- SPF record: Helps prevent email spoofing
- DKIM record: Improves email deliverability by adding digital signatures

Step 5: Access your email server software:
Accessing your email server with a VPS requires different steps depending on your operating system. Linux is considered the better option because you don’t need to pay for licensing. Fortunately for you, I’ve created separate instructions for Windows and Linux.
Launching your email server with Windows:
Connect to your VPS:
First, you will need to open RDP (Remote Desktop Connection) on your local computer. Your VPS provider should have given you an IP address and login credentials. Once you have entered the credentials, double-check them and then click “Connect.”
Access the email server software:
Once you have logged into your VPS, depending on the email server software you have installed (like Postfix or Exim), you will go to the Windows start menu and use the search tool to find and launch it.
To log into the webmail interface, you can open any web browser and go to the URL that your hosting provider gave you. You can usually access it with your domain name, such as “webmail.yourdomain.com.”
Launching your email server with Linux:
Connect to your VPS:
First, open the terminal application on your computer. Then, use the ssh command to connect to your server. Provide your username and server IP. The command will look like this: ssh username@server_ip_address. Make sure to fill in the “username” and “server_ip_address_” with the proper information. You should now be prompted to enter your password.
Access email server software:
Now that you have connected to your VPS, you can use the command-line commands to interact with the email server software (such as Postfix or Exim) installed on it. You can access the webmail version through any web browser by going to the URL provided by your hosting provider. It will be something along the lines of “webmail.yourdomain.com.”
You can check the mail queue by using commands like “mailq” (Postfix) to see any pending emails.
To configure your email server’s settings, you can open the configuration files using a text editor such as Nano or Vi.
If you are having issues with email delivery, you can check the server logs by using commands such as “tail—f/var/log/mail.log.”

Step 6: Create email accounts:
Navigate to user management:
Now that you have successfully accessed your email server software, you and your team can create email accounts.
Enter account details:
Username: The part of the email address before the “@” symbol (e.g., “john”).
Password: The password for accessing the email account.
Domain: The domain name associated with the email address (e.g., “yourcompany.com”).
Set storage limits (optional):
Depending on why you are self-hosting your email server, you might want to set some storage limits. Not all email server software will have the option, but some will let you set a maximum storage quota for each individual mailbox.
Save the account:
Click “Create” or “Save” to finalize the new email account.
You can follow these steps for each individual email you want to create.
Step 7: Secure your server:
At last, it’s time to secure your server. There are a few ways you can do this, but for maximum security, I recommend you do all three options I’ve described below:
- Enable SSL/TLS encryption: Protects email communication with secure connections
- Set up firewall rules: Filter incoming traffic to prevent unauthorized access
- Regular updates: Keep your email server software and operating system up to date with security patches

Frequently asked questions:
How is a self-hosted email server better than third-party email services like Gmail or Outlook?
A self-hosted email server is better than most third-party email services because it gives you complete control over your email data and system. This gives a lot more customization, better security made specifically for you, and more privacy when compared to Gmail or Outlook. The only downside is that it requires a lot more technical skills to set up and maintain.
Can I use the same VPS to host both my website and email server?
Yes, you can absolutely use the same VPS for your website and email server. I recommend it because you should already be familiar with the VPS layout from setting up your website when creating your email server. A VPS provides enough flexibility to set up separate environments for each service within the same server, making it easy to manage both in one place.
Can I switch VPS providers after setting up my email server?
Yes, you can switch VPS providers after setting up your email server. However, this requires a migration process. To ensure a smooth transition without damaging your email services, you need to back up your email data, set up your email accounts on the new server, and update your domain’s DNS records to point to the new provider.
What is the difference between Postfix, Dovecot, and Exim?
Postfix and Exim are both Mail Transfer Agents (MTAs) responsible for sending emails between servers. Dovecot is a Mail Delivery Agent (MDA) that primarily handles storing and accessing emails on the server using protocols like IMAP and POP3. Thus, it is the primary tool for users to retrieve their emails. Essentially, Postfix/Exim delivers emails to Dovecot, which then allows users to access them through their email client.
Wrapping it all up
You have gone through all the steps to successfully create your own email server using a VPS, from picking the right VPS and email server software to creating your own emails and making sure your server is secure. Now you can have confidence that your business will thrive. With more customization and less worrying about 3rd party issues.
If this guide helped you even a little and you think it could help one of your friends, we would appreciate it if you shared it with them. A share can go a long way, and that’s how I can keep writing educational content like this.
