Postfix is popular open source mail transfer agent which runs on most of Unix like OS. It comes with a lot no. of parameters, most of them carry default values. Small updations to these in considering with your environment specific will make your mail server up and running in no time.

The following sections will help you out in installing and configuring postfix on ubuntu box :

1.1 Installation

With the help of package manager we can fetch all the dependencies packages and install them.

apt-get install postfix

1.2 Configuration

Postfix ships with configuration file main.cf. Your configuration file should look like below

smtpd_banner = $myhostname ESMTP
biff = no
append_dot_mydomain = no
readme_directory = no
##SSL Conf
smtpd_tls_cert_file = /etc/postfix/ssl/server.crt
smtpd_tls_key_file = /etc/postfix/ssl/server.key
smtpd_use_tls = yes
smtpd_tls_security_level = may
smtpd_tls_loglevel = 1
smtpd_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
###Domain Conf
myhostname = mail.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = smtp_uat.example.com, example.com, smtp_uat,localhost.localdomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

Finally, make an entry in /etc/mailname for your domain

email.example.com

Dovecot

2.1 Installation

Use package manager to install dovecot

apt-get install dovecot-core dovecot-imapd dovecot-pop3d,dovecot-common

2.2 Configuration

Update your dovecot.conf as below

disable_plaintext_auth = yes
mail_privileged_group = mail
mail_location = mbox:~/mail:INBOX=/var/mail/%u
userdb {
driver = passwd
}
passdb {
args = %s
driver = pam
}
protocols = imap pop3
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
2.3 Create User and home directory

Execute following commands in shell to create user and home directory

#useradd example_user.com -d /home/example_user.com -s /bin/nologin
#cd /home && mkdir example_user.com
#chown -R example_user.com:example_user.com example_user.com/
#passwd example_user.com

2.4 Inbox Location

Inbox location for user is /var/mail/example_user

Note : Here you will see all incoming mails information