This article outlines basic steps for setting up a mail server using popular components such as Postfix and Dovecot. Please note that mail server setup may vary depending on the selected software and operating system, as well as the environment’s specific settings. This article is focused on the Ubuntu and Debian operating systems.
Please note: The use of email sending services must not violate our terms of use. Suspicious requests will be rejected and, if necessary, accounts will be blocked.
Install Cloud VM using our guide. The minimum available configuration—1vCPU and 2 GB RAM—will be enough to install and run a mail server on your VM.
Check the Network settings tab in the machine settings. The interface must be set to the public to access the internet.
However, if you first chose the option private method, then you need to get a floating IP address to access the internet.
Please note: By default, Gcore Cloud VM has limits on SMTP port 25. In order to open a port and successfully install a mail server, contact support and click Create Ticket.
Connect to your Gcore Cloud VM via either SSH or the VNC concole 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 update
sudo apt-get install postfix
During Postfix installation, you will be prompted to select a configuration type. Select the Internet Site
option and enter the fully qualified hostname of your server, then click <Ok>
.
Navigate to the Postfix configuration file:
sudo nano /etc/postfix/main.cf
In this configuration file, edit the following parameters:
myhostname = your_server_domain.com
mydestination = your_server_domain.com, localhost.localdomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myhostname: Specify the fully qualified domain name of the Virtual Server on which Postfix is running.
mydestination: Specify the domains for which mail will be delivered locally instead of being forwarded to another host.
mynetworks: Specify a list of networks or IP addresses from which mail messages are allowed to be sent through this server.
Save the changes and restart Postfix:
sudo service postfix restart
More information about Postfix is available in their documentation.
Dovecot is an IMAP (Internet Message Access Protocol) and POP3 (Post Office Protocol 3) server that provides access to mailboxes. It is required during the mail server setup, so installing it will be the next step. Use the following command to install Dovecot:
sudo apt-get install dovecot-imapd dovecot-pop3d
Add the following SSL parameters:
listen = *, ::
ssl = required
ssl_cert = </etc/ssl/certs/ssl-cert-snakeoil.pem
ssl_key = </etc/ssl/private/ssl-cert-snakeoil.key
Insert the required SSL parameters below, as noted in the screenshot, after listen = *, ::
.
Save your changes and restart Dovecot:
sudo service dovecot restart
Now you have successfully configured and installed Postfix and Dovecot, you can create mailboxes for users. For each user, run this command:
sudo useradd -m -s /usr/sbin/nologin username
sudo passwd username
Create a password for each user and retype it. The password will be saved automatically.
Next, you should manage the DNS settings. Use our PD guide to get step-by-step configuration instructions.
Restart Postfix and Dovecot to apply the changes.
sudo service postfix restart
sudo service dovecot restart
You can use an email client (for example, Thunderbird) to send a test email from one of the email addresses you created. After sending a test email, check your email client or webmail to receive this email. Analyze the Postfix and Dovecot logs, located in the following directory:
/var/log/mail.log
Was this article helpful?
Discover our offerings, including virtual instances starting from 3.7 euro/mo, bare metal servers, AI Infrastructure, load balancers, Managed Kubernetes, Function as a Service, and Centralized Logging solutions.