Use apt-get or yum to install Postfix.
~]# yum install postfix
Sendmail should not be installed. However, just to be certain, uninstall sendmail.
~]# yum erase sendmail
The hostname of your Linux server can be something unique, such as mail1. Ensure your DNS server is able to resolve the hostname of your mail server to the IP address of your mail server. It is farily common for the DNS to resolve a variety of hostnames to the Postfix server, such as in the example below.
In the /etc/postfix/main.cf file, set mydestination to contain your domain name. This is how Postfix knows that firstname.lastname@example.org is a valid email address.
mydestination = example.com
For the initial setup, configure Postfix to use user accounts listed in the /etc/passwd file on the Linux system.
In the /etc/postfix/main.cf file, set home_mailbox to Maildir/, so that emails are stored at /home/username/Maildir/. Also ensure that mailbox_command has no value. This will ensure that when a new user account is created, the new users home directory will contain the mail directory, such as /home/jane.doe/Maildir/.
home_mailbox = Maildir/ mailbox_command =
In the /etc/postfix/main.cf file, ensure local_recipient_maps is not commented out, as this line is needed in order for Postfix to locate the accounts listed in the /etc/passwd file.
local_recipient_maps = unix:passwd:byname $alias_maps
In the /etc/postfix/main.cf file, set mynetwork_styles to host, for security.
mynetwork_styles = host
In the /etc/postfix/main.cf file, set inet_interfaces to all, to allow remote hosts to be able to connect to your Postfix server.
inet_interfaces = all
In the /etc/postfix/main.cf file, set smtpd_recipient_restrictions, for security.
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
Restart Postfix, and ensure Postfix is active and running.
~]# systemctl start postfix ~]# systemctl enable postfix ~]# systemctl status postfix
It is not a good idea to open ports 25, 110, and 143 in your Internet facing router, as Postfix has not been secured with authentication, encryption, and a spam filter. Opening up an unsecured mail server to the Internet creates the possibility for your email server to become a spam relay, which is something you want to prevent.
You can now create and read emails using the mailx command on the Linux system.