Postfix — The Mail Transfer Agent | Installation and Configuration on Debian and Ubuntu Server
The Electronic Postman — Just like mail, email also has a postman. Mail Transfer Agent is software that functions to sort and send emails to the destination computer with a simple mail transfer protocol.
Simple Mail Transfer Protocol is the standard protocol generally used for sending email. So what is Postfix?, Postfix is Mail Transfer Agent.
Installation
Before installation make sure the system is updated and has user privileges.
Installing Postfix
apt install postfix
Configuration
The configuration file is located in the /etc/postfix/ directory; The main configuration file for Postfix is located in /etc/postfix/main.cf.
When the Postfix installation process is complete we will be faced with the setup configuration. I’m assuming that you did the default setting by simply confirming yes to each configuration setting.
SSL configuration for Postfix.
Standard snake oil certificate
apt install openssl ssl-cert
Generate a self-signed SSL certificate, for example, we will generate a self-signed SSL certificate with a 2048-bit RSA key and will store it with a self-signed name.
openssl req -nodes -newkey rsa:2048 -keyout /etc/ssl/private/self-signed.key -out /etc/ssl/certs/self-signed.crt
Customize configuration
nano /etc/postfix/main.cf
Configure to use a self-signed SSL certificate
smtpd_tls_cert_file=/etc/ssl/certs/self-signed.pem
smtpd_tls_key_file=/etc/ssl/private/self-signed.key
Change the hostname and domain of the mail server; for example, we will declare mail.sxs3c.org as the hostname and sxs3c.org as the domain.
hostname = mail.sxs3c.org
mydomain = sxs3c.org
Change the home mailbox directory and set a size limit; for example, we will declare ~/mailbox as home mailbox and set the size to 512M per user.
home_mailbox = mailbox/
mailbox_size_limit = 51200000
A trusted remote SMTP server that can relay through the server.
Change network. For example, we will use a local network; it is important to only use local network addresses to avoid unauthorized users from using your mail server.
mynetworks = 10.20.30.0/24, [2001:ABC:FE::]/64
Testing
Test the results, for example, the server gets the ip address 10.20.30.40.
Connect with clients
nc 10.20.30.40 25
Sending a test mail.
Example
helo test
mail from: <test@domain.com>
rcpt to: <root>
data
subject: test
test mail server
.
quit