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.

Shell
1apt-get install postfix

1.2 Configuration

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

Plain text
1smtpd_banner = $myhostname ESMTP
2biff = no
3append_dot_mydomain = no
4readme_directory = no
5##SSL Conf
6smtpd_tls_cert_file = /etc/postfix/ssl/server.crt
7smtpd_tls_key_file = /etc/postfix/ssl/server.key
8smtpd_use_tls = yes
9smtpd_tls_security_level = may
10smtpd_tls_loglevel = 1
11smtpd_sasl_auth_enable = yes
12smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
13###Domain Conf
14myhostname = mail.example.com
15alias_maps = hash:/etc/aliases
16alias_database = hash:/etc/aliases
17myorigin = /etc/mailname
18mydestination = smtp_uat.example.com, example.com, smtp_uat,localhost.localdomain, localhost
19mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
20mailbox_size_limit = 0
21recipient_delimiter = +
22inet_interfaces = all
23smtpd_sasl_type = dovecot
24smtpd_sasl_path = private/auth
25smtpd_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

JavaScript
1disable_plaintext_auth = yes
2mail_privileged_group = mail
3mail_location = mbox:~/mail:INBOX=/var/mail/%u
4userdb {
5driver = passwd
6}
7passdb {
8args = %s
9driver = pam
10}
11protocols = imap pop3
12service auth {
13unix_listener /var/spool/postfix/private/auth {
14group = postfix
15mode = 0660
16user = postfix
17}
182.3 Create User and home directory
19
20Execute following commands in shell to create user and home directory
21
22#useradd example_user.com -d /home/example_user.com -s /bin/nologin
23#cd /home && mkdir example_user.com
24#chown -R example_user.com:example_user.com example_user.com/
25#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