
Postfix is a Mail Transfer Agent(MTA) for routing and delivering electronic mail(email). Dovecot is a secure IMAP and POP3 Mail Delivery Agent(MDA). These two open-source applications work well with Roundcube, an email client primarily famous for its clever use of Ajax technology. In this guide, you'll install Postfix, Dovecot, and Roundcube on Ubuntu 20.04. This guide uses the domain example.com and the server name mail.example.com.
Before you begin, make sure you have the following:
SSH to your server and install the Postfix server by running the command below.
You'll get the Postfix configuration screen, as shown below. Press Tab and Enter to continue.
On the next screen, select Internet Site, then Tab and Enter.
Enter the system mail name, which is your domain name. For instance, the server name is mail.example.com, so you'll enter example.com here.
Back up the /etc/postfix/main.cf file, and create a new one.
Enter the information below to the new file. Replace example.com with your domain name throughout the file. Make sure the value of smtpd_tls_cert_file and smtpd_tls_key_file point to your SSL certificate.
Save and close the file.
The main.cf configuration file instructs postfix to look for email domains in the /etc/postfix/virtual_mailbox_domains file. Create the file:
Add the information below to the file and replace example.com with your domain name.
Use the postmap command to change /etc/postfix/virtual_mailbox_domains to a format recognizable by Postfix. Run this command every time you edit the file, for instance, after adding more domains to the file.
Edit the /etc/postfix/master.cf configuration file to enable the SMTP service.
Find the entry below.
Remove the pound symbol at the beginning of the line.
Save and close the file.
Install the Dovecot package and all the dependency packages required to run the imap, pop3, and lmtp service.
Edit the /etc/dovecot/conf.d/10-mail.conf file to instruct Dovecot on the directory to look for mails.
Find the entry below.
Change to:
Save and close the file. The %d represents the domain, and %n represents the users. This means that you'll need to create a sub-directory in the /var/mail/vhosts for every domain receiving emails on your server.
Create the first sub-directory and replace example.com with your domain name.
Repeat the command above for every other domain that you want to receive emails for in your server while replacing example.com with the domain name. For instance, if you also intend to receive emails for the example.net domain, run the command below.
Create a Vmail user and group for the Dovecot service.
Create the vmail group.
Create a vmail user and add the user to the vmail group.
Assign the ownership of the /var/mail/vhosts/ to the vmail user and group.
Edit the Dovecot 10-master.conf file.
Locate the entries below.
Remove the pound symbol before the port and ssl entries, as shown below, to allow Dovecot to use port 993 and SSL for secure IMAP.
Locate the entries below.
Remove the pound symbol before the port = 995 and ssl = yes parameters.
Enable the lmtp service. Locate the entries below.
Change the configuration to:
Locate the Dovecot authentication socket configurations below.
Change the configuration to:
Save and close the file.
Configure Dovecot to use secure authentication. Edit the Dovecot 10-auth.conf file.
Find the entry below.
Uncomment the setting above by removing the # character to disable plain text authorization.
Find the entry below.
Change the authentication mechanisms from plain to plain login.
Disable the Dovecot default authentication behavior that requires users to have a system account to use the email service. Find the line:
Add a pound symbol at the beginning of the line to comment it out.
Find the line:
Remove the # symbol at the beginning to enable Dovecot to use a password file.
Save and close the file.
Edit the Dovecot password file, auth-passwdfile.conf.ext.
The file looks similar to the one shown below.
Make the changes to the file, as shown below.
Save and close the file.
Create the /etc/dovecot/dovecot-users password file. This file is a plain text database that holds email users on your server.
Add the users that you want to use the email service to the file by following the format below. Replace EXAMPLE_PASSWORD with a strong password. Also, replace example.com with your domain name.
Save and close the file.
Configure Dovecot to Use the SSL Certificate. Open the /etc/dovecot/conf.d/10-ssl.conf file.
Find the line:
Change the ssl value from yes to required.
Locate the two entries below.
Change the two entries above and make sure they are pointing to the SSL certificate for your domain. For instance, if you are using the Let's Encrypt certificate, your entries will be similar to those shown below. Replace example.com with your domain name.
Save and close the file.
Restart the postfix and dovecot services to use the new settings.
To access Postfix and Dovecot servers, install Roundcube email client.
Press Enter to configure the database for use with Roundcube.
On the next screen, enter a MySQL password to use with Roundcube.
Press Tab and Enter.
Repeat the same password then hit Tab and Enter to continue.
Open your website SSL configuration file from the /etc/apache2/sites-enabled directory. Run the command below and replace example.com with your domain name.
Your website configuration file will be similar to the one shown below.
Add the entry Alias /mail /usr/share/roundcube after the entry ServerName example.com as shown below.
Save and close the file.
Restart Apache.
To login to the email server using Roundcube, enter the URL shown below and replace example.com with your domain name.
You should see a screen similar to the one shown below. Enter the username and password you defined in the Dovecot password file, and log in.
Once logged in, you can send and receive emails from the Roundcube dashboard.
0 Comments
Be the first to comment and share your perspective with the community.