Creating a DNS Mail Exchange (MX) record is a pivotal step in the process of setting up a mail server. An MX Record directs email messages to be routed through your domain to the correct mail server.
The MX record also identifies the server that should receive email for the domain and assigns a preference value for mail delivery if multiple mail servers are available.
To create an MX record, you first need to access the DNS management interface provided by your domain registrar or DNS hosting provider. Within this interface, you would typically select the domain you are working with.
Navigate to the DNS settings or DNS management page. Find the option to add a new record. Once there, you will select ‘MX’ as the record type and enter the necessary details.
The essential components of an MX record include the Priority and the Destination. The Priority is a number that specifies the precedence of the mail server. Lower numbers denote higher priority.
The Destination is the domain name of the mail server that will receive the emails for your domain. After entering these details, save the changes.
It is crucial to ensure that the details, especially the destination, are entered correctly. Also verify the MX record post-creation, as improper configuration can lead to the misrouting or loss of emails.
After setting up the MX record. It may take some time, usually up to 48 hours, for the changes to propagate across the internet.
Configure a Mail Server on Ubuntu 22.04 Using the Modoboa Installer
Log into your VPS using an SSH client like Putty. If you are on a Linux machine you can log in using the terminal.
SSH, or Secure Shell, is a protocol used to securely log onto remote systems. You can use the
ssh command in the Linux terminal to connect to another system.
ssh [user]@[hostname or IP address]
- [user] is the username you want to log in as.
- [hostname or IP address] is the address of the system you want to connect to.
After you log in, always ensure your system is up-to-date:
sudo apt update && sudo apt upgrade -y
Install Required Dependencies
Modoboa has a number of dependencies that can be installed using:
sudo apt-get install -y git python3-virtualenv python3-pip
Use the Modoboa Installer
To simplify the process, Modoboa provides an installer script:
git clone https://github.com/modoboa/modoboa-installer
Next, move to the
modoboa-installer directory and generate a configuration file. Substitute
example.com with your specific domain name.
cd modoboa-installer sudo ./run.py –stop-after-configfile-check example.com
installer.cfg configuration file using your favorite text editor, for example, nano:
sudo nano installer.cfg
To secure a legitimate TLS certificate from Let’s Encrypt for your mail server, modify the value of
letsencrypt within the
[certificate] section. Also change the email address to your own.
By default, the Modoboa installer is configured to set up a PostgreSQL database server, as evidenced by the corresponding lines in the configuration file.
Should you prefer to utilize MariaDB as the database server, alter the engine from
mysql. In this instance, Modoboa will proceed to install MariaDB in place of MySQL.
After you are done making changes you can save the file and exit. Hit `Ctrl+O` and then press `Enter` to validate your choice. To close, press `Ctrl+X`.
Subsequently, it is recommended to employ a Fully Qualified Domain Name (FQDN) as the hostname for your mail server, for instance, mail.example.com. Execute the ensuing command to establish the hostname.
sudo hostnamectl set-hostname mail.example.com
You can now run the installer. Before you do that make sure DNS records are propagated to the Internet. You can use a tool like
If everything is ok run the following command to start the installation of Modoboa. Replace example.com with your own domain. The installation can take some time so be patient. Once the installation is done restart the server.
sudo ./run.py –interactive example.com
Should an error occur during the installation, leveraging the `–debug` option will enable you to view more comprehensive output details.
sudo ./run.py –interactive –debug example.com
Access Modoboa Web Interface
Once everything is set up, access the Modoboa web interface by navigating to:
You should see the Modoboa login page. The default credentials are:
Make sure to change the default password immediately after logging in! Go to
Profile to change the password.
Domains and add your domain. Enabling DKIM signing is strongly advised as it can significantly aid in enhancing the reputation of your domain.
In the subsequent screen, you have the option to establish an admin account for your domain. The SMTP protocol mandates that a mail server must possess a firstname.lastname@example.org address.
The domain is now added as shown below. To add email addresses or users click on it.
Click on mailboxes to start adding email addresses
When the window shown below opens click on “Add” then “Account” to add an email address.
Next, select ‘Simple user’ as the role. Input an email address in the ‘Username’ field and provide a password.
On the following screen, you have the option to create an alias for this email address, if desired.
Send Test Email Using Webmail
To access the webmail, it is necessary to first log out of the admin account and then input the user credentials.
Click on webmail then compose an email. Send it to a public email address like Gmail or yahoo and see if you will receive the email. If you do receive the email it means you are able to send email.
Next, send an email from your Gmail or any other email address to your Modoboa email account. If you receive the email it means your server is able to receive emails.
Solutions If you can not send Emails
If you encounter the below-mentioned error in the /var/log/mail.log file, it signifies that the policy daemon is not operational.
postfix/smtpd: warning: connect to 127.0.0.1:9999: Connection refused
postfix/smtpd: warning: problem talking to server 127.0.0.1:9999: Connection refused