How to Set Up a Mail Server on a VPS 

Running your own mail server allows you to move away from third-party services and take charge of your email delivery, authentication, and security. This guide walks you through the entire process in a clear and simple way, so you can manage email confidently on your Contabo VPS

Choose Your Platform 

Before you start with the setup process, begin by selecting the right software for your server type. 

On Linux, Postfix and Dovecot work well together. Postfix handles outgoing email, while Dovecot manages incoming email securely. They give you full control over SMTP and authentication. 

On Windows, hMailServer is a strong option. It supports SMTP, IMAP, and POP3 and remains lightweight and easy to configure. 

Basic Installation 

Linux (Postfix) 

To start, install Postfix with a single command: 

sudo apt update && sudo apt install postfix 

This adds the core email services you need for sending mail from your VPS. 

Windows (hMailServer) 

Start by downloading the hMailServer, then run the installer. Before installation, enable .NET Framework 3.5 using the Windows Server Manager. Once installed, you now have access to a full email management GUI. 

Set Up Your Domain and DNS 

Next, connect your domain to your server. In your DNS zone: 

  • Add an MX record pointing to your server’s hostname. 
  • Add an A record that maps the hostname to your VPS IP. 

For proper deliverability, also set up Reverse DNS (PTR). Many email providers rely on PTR validation before accepting incoming mail from your server. 

Secure Your Server 

Security when operating a mail server is important. Implement these steps right away: 

  • Enable SSL/TLS encryption with Let’s Encrypt. 
  • Require SMTP authentication so only trusted users can send email. 
  • Add SPF, DKIM, and DMARC DNS records. These boost deliverability and protect your domain from spoofing attempts. 

These measures help keep your mail safe and reduce the chances of your messages landing in spam folders. 

Add Spam and Virus Protection 

To keep your inbox clean, install anti-spam and antivirus tools. 

Linux 

Use SpamAssassin for spam filtering. 

Windows 

hMailServer integrates well with the open source ClamWin Antivirus, giving you basic virus scanning support. 

Both tools help keep unwanted mail out and protect your users from harmful attachments. 

Testing and Monitoring 

After setup, send a test email to verify that everything works. 

On Linux, use monitoring commands like: 

postqueue -p 

tail -f /var/log/mail.log 

These tools help track your mail queue and confirm that messages are sent and delivered successfully. 

Use an email client such as Thunderbird to test IMAP and SMTP connectivity. 

Need a Simpler Setup? 

If you prefer managing email through a graphical interface, Contabo supports Plesk and cPanel. These platforms include built-in mail server tools, easy DNS editors, spam filters, and user-friendly SMTP configuration panels. They reduce the need for terminal commands and simplify daily mail management. 

Watch Our YouTube Video on Setting Up a Mail Server on VPS 

If you are more of a visual learner and prefer a visual walk-through, we have a video on our YouTube ready for you. 

Conclusion 

Running your own mail server gives you control, better privacy, and the flexibility to configure your email environment exactly how you want. With a Contabo VPS, you can build a secure and reliable email system that fits your needs without emptying your pockets. 

Scroll to Top