Set up a mail server on a Gcore Cloud VM with Postfix and Dovecot on Ubuntu or Debian, including port 25 unblocking.
This article outlines basic steps for setting up a mail server using popular components such as Postfix and Dovecot. Mail server setup may vary depending on the selected software and operating system, as well as the environment’s specific settings. This guide focuses on Ubuntu and Debian operating systems.
Outbound traffic on port 25 (SMTP) is blocked by default to prevent spam. Before setting up a mail server that requires port 25, contact the Gcore support team to request unblocking with a business justification. The use of email services must comply with Gcore terms of use; accounts violating these terms will be blocked.
Install a Cloud VM using the VM creation guide. The minimum available configuration (1vCPU and 2 GB RAM) is sufficient to install and run a mail server.
Check internet access.
Check the Network settings tab in the machine settings. The interface must be set to the public to access the internet.
If the private network method was initially selected, a floating IP address is required to access the internet.
Ensure port 25 is unblocked before proceeding with mail server installation. See the warning at the top of this guide for details.
Connect to the Gcore Cloud VM via SSH or the VNC console in the Customer Portal.
Install Postfix.
Postfix is one of the popular Mail Transfer Agents (MTAs) responsible for sending and delivering mail messages. To install Postfix, run the following commands:
sudo apt-get updatesudo apt-get install postfix
During Postfix installation, a prompt appears to select a configuration type. Select the Internet Site option, enter the fully qualified hostname of the server, and click <Ok>.
Configure Postfix.
Navigate to the Postfix configuration file:
sudo nano /etc/postfix/main.cf
In this configuration file, edit the following parameters:
Dovecot is an IMAP (Internet Message Access Protocol) and POP3 (Post Office Protocol 3) server that provides access to mailboxes. To install Dovecot, run the following command:
Create a password for each user and retype it. The password will be saved automatically.
Add DNS records.
Configure DNS settings for the mail server. Refer to the DNS setup guide for step-by-step instructions.
Test and verify.
Restart Postfix and Dovecot to apply the changes.
sudo service postfix restartsudo service dovecot restart
Use an email client (for example, Thunderbird) to send a test email from one of the created email addresses. After sending a test email, verify receipt in the email client or webmail. The Postfix and Dovecot logs are located in the following directory: