Postfix is an MTA(Mail Transfer Agent) responsible for mail sending and receiving. There is many other open source MTA available in Linux but Postfix is created with security in mind and it’s an successor of Qmail and Sendmail programs. Postfix is designed to be modular package instead on a single binary like sendmail. It also can be enhanced with third party applications like SpamAssassin for anti-spam and procmail for email delivery. Postfix is very configurable but first let’s start with Postfix installation and basic configuration
Let’s install the Postfix
# yum install postfix -y
Because there are lot’s of binary for individual tasks, at the first look postfix configuration seems very confusing.
Let’s start with directory structure..
/etc/postfix/main.cf : It’s an primary configuration file for postfix global configuration.
/etc/postfix/master.cf : It’s also a primary configuration file for postfix binary.
/var/spool/postfix : Postfix email processing directory.
Here we are not digging deep into postfix, we are just making a basic configuration..
open your mail.cf config file into your favorite editor.
Postfix default file has tons of configurations, just make a copy of config file and let’s start with scratch.
myhostname = mail.sector19.com mydomain = sector19.net myorigin = $mydomain mydestination = $myhostnamem, $mydomain, localhost.$mydomain, , localhost mynetworks = 127.0.0.0/8 [::1]/128 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all
myorigin : my origin specify the email domain when email is generated. For example if you send an email to root user and your origin is set to $mydomain mail will send to firstname.lastname@example.org.
mydestination : mydestination parameter specify the domain names for which server will accept mails.
mynetworks : mynetworks parameter specify the IP or network address which can relay email through postfix.
aliases_maps : Alias maps define the mapping of virtual name with system users.
open the file aliases and you can add aliases in the format of
if we send any email to demoadmin it will be delivered to root users.
after any changes in alias database you need to recreate the alias database by executing
After any changes in postfix you need to restart the service by executing
service postfix restart
systemctl restart postfix
Let’s send an test email and verify the configuration
# yum install mailx # echo "test email to zolan user" | mail -s "Hi zolan" zolan@localhost
what to do next.
- Postfix security
- Postfix with spamassession