
Let’s see the installation and configuration process for the Postfix mail server on a Debian Linux system. Â
Step 1: Postfix Installation Â
Step 1: Postfix Installation
Postfix is regularly used due to its ease of use, minimal settings, and extensive usage. On your Debian-based Linux system, run the following command to install Postfix: Â
Internet Sitesudo apt install postfix Â
Before installing Postfix, it would be best to uninstall Sendmail from your system if it is already installed. Â
sudo apt remove sendmail Â
Postfix will ask you a few questions throughout the installation process. In the package configuration, first, select the Internet site, and next, enter the domain name. Â
Like other Linux applications, Postfix also saves its configuration in files, and this postfix configuration is found in the main.cf file. Always make a backup of the default main.cf file. Â
Step 2: Configure Postfix SMTP Server Â
To begin, open the main.cf file in the text editor and modify its contents. The file contains a lot of basic information, such as mydomain and myhostname – the SMTP server. To get the server to function, adjust the settings. Â
vim /etc/postfix/main.cf Â
Step 3: Verify Postfix Mail Server Â
You can add your domain name and IP address to the host file, and also, you can send your first mail via the postfix server by using the below command. Â
hostnamectl set-hostname mail.fatih.com Â
echo "192.168.0.100 fatih.lab mail.fatih.lab" >> /etc/hosts Â
reboot Â
By using the following command, check the contents of the hostname file after rebooting the system. Â
hostname && cat /etc/hostname && hostname -s Â
# Output  mail.fatih.com  mail.fatih.com  mail Â
Next, verify your port number by using the below command: Â
netstat –tlpn Â
Now compose your first message and check the progress. Then, use the command to send your first mail: Â
echo "my first mail content" | mail -s "Hello Postfix" root Â
After completing this step, check the Maildir folder listed in the main.cf file. If everything is fine then the email you have sent will be here. Â
cat /Maildir/new/[Press Tab] Â
Install and Configure Dovecot Â
In this process, we’ll use Dovecot IMAP as our mail delivery agent to send emails to a local recipient’s mailboxes. IMAP is a protocol that operates on ports 143 and 993 (SSL), and with POP3, this is not the case. Users cannot set up several directories on the server. Â
Run the following command to install the Dovecot core server and Dovecot IMAP package on Debian. Â
sudo apt install dovecot-core dovecot-imapd Â
After the Dovecot installation, first, create a connection between your Maildir folder and Dovecot. Then, locate the following lines in /etc/dovecot/conf.d/10-auth.conf and modify them Â
disable_plaintext_auth = no Â
auth_mechanisms = plain login Â
To store emails in the Maildir location, open the/etc/dovecot/conf.d/10-mail.conf file and add the following line. Â
mail_location = maildir:~/Maildir Â
The final file to modify is /etc/dovecot/conf.d/10-master.conf. Search for the Postfix smtp-auth block and change the following: Â
# Postfix smtp-auth Â
unix_listener /var/spool/postfix/private/auth
{ Â Â
mode = 0666 Â Â
user = postfix   Â
group = postfix Â
} Â Dovecot’s default port is 143. Restart the dovecot service and check the port number: Â
netstat –tlpn Â
To send an email, create a new user and connect to port 25 with the below command: Â
adduser test Â
Connect to port 25 using nc command: Â
nc localhost 25 Â
The command structure you need to edit the email content: Â
mail from: root  rcpt to: usertest  data  subject: subjecttest  my mail content   quit Â
Finally, ensure the mail is sent successfully, and this configuration process should deliver the mail to the Maildir folder. Verify it by using the following command: Â
cat /home/testuser/Maildir/new/[Press Tab]Â
To get more updates you can follow us on Facebook, Twitter, LinkedIn
Subscribe to get free blog content to your Inbox
Previous Post
Steps to enable SSH on Debian 9


