Thursday, September 19, 2024

Guide: How to Set Up a Mail Server on AWS

If you’re interested in setting up a secure, efficient, and custom mail server, this tutorial will help you. You’ll learn how to set up a mail server on Amazon Web Services (AWS), one of the most reliable cloud platforms. For our email services, we’ll use Postfix as our mail transfer agent (MTA), Dovecot for the IMAP/POP3 server, and Roundcube for our webmail client.

Please note: Setting up your own mail server requires a degree of technical knowledge, and managing it responsibly is crucial to prevent issues like your server being used for spam.

Automatically Set Up an E-mail Server on AWS

I’ll preface this article by mentioning you can easily set up a personal e-mail server using iRedMail.  I’d recommend it over the following tutorial.

Manually Configuring an E-mail Server on AWS 

Step 1: Set Up an AWS EC2 Instance

First, you’ll need an AWS account. Once logged in, set up a new EC2 instance. You can find a detailed guide here.

In terms of the instance type, an instance like a t2.micro should suffice for a small mail server.

Ensure your instance’s security group settings allow inbound traffic for the following ports: 22 (SSH), 25 (SMTP), 143 (IMAP), 587 (SMTP), and 993 (IMAPS).

Step 2: Install Postfix

Once your EC2 instance is running, connect via SSH. Update your system and install Postfix, a free and open-source mail transfer agent.

sudo apt update
sudo apt upgrade
sudo apt install postfix

During the installation, you’ll be prompted to configure Postfix. For ‘General type of mail configuration’, select ‘Internet Site’. Enter your domain for ‘System mail name’.

Step 3: Install and Configure Dovecot

Dovecot is a popular open-source IMAP/POP3 server. Install Dovecot with the following command:

sudo apt install dovecot-imapd dovecot-pop3d

Configure Dovecot by editing the following file:

sudo nano /etc/dovecot/dovecot.conf

Ensure the protocols line is uncommented and looks like this: protocols = imap pop3 lmtp

Step 4: Create Email Accounts

We’ll be using Linux system users for our mail accounts. To add a new user, use the adduser command:

sudo adduser [username]

Step 5: Install and Configure Roundcube

For our webmail, we’ll be using Roundcube. It’s a browser-based multilingual IMAP client with an app-like user interface. You can download and install it from here.

Configure Roundcube to connect to your Dovecot IMAP server and set Postfix as your SMTP server.

Step 6: Test Your Setup

Finally, it’s time to test your mail server. From another email account, send an email to the user you created. Check your Roundcube client to see if the email has been received. Also, try to send an email from your new server to another account.


This is a basic setup and may need to be further secured and optimized according to your needs. Don’t forget to maintain your mail server properly to keep it secure and efficient over time.

Disclaimer: Please keep in mind that running your own mail server comes with a lot of responsibilities. Ensure you comply with AWS’s policies and the laws of your country to prevent your server from being used for spam or other malicious activities.

Setting up a mail server on AWS is a fantastic way to gain greater control over your digital communications. While it does require some technical knowledge, the benefits can be substantial. We hope this guide has provided a clear starting point.

Related Articles

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles