Setup postfix and dovecot on ubuntu 14.04

Installing and configuring  postfix

Step 1 » Assign static IP and hostname and add a host entry for the host name .
Assign hostname in /etc/hostname

Add a hostentry in /etc/hosts
Step 2 » Update the repositories.
[email protected]:~$ sudo apt-get update
Step 3 » Install postfix and dependencies . Press enter for all prompted questions during installation. we will do that in the next step.
[email protected]:~$ sudo apt-get install postfix
Step 4 » After installation issue the below command to configure postfix.

[email protected]:~$ sudo dpkg-reconfigure postfix

Now you will be prompted for set of details . choose the following values and replace with your domain name.
1. Internet Site
3. service-labs
4., localhost.localdomain, localhost
5. No
6. [::ffff:]/104 [::1]/128
7. 0
8. +
9. all

Step 5 » Now configure Postfix for SMTP-AUTH using Dovecot SASL by adding the below lines to postfix config file /etc/postfix/ .
home_mailbox = Maildir/
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes

Step 6 » Now generate a digital certificate for tls. Issue the commands one by one and provide details as per your domain.
[email protected]:~$ openssl genrsa -des3 -out server.key 2048
[email protected]:~$ openssl rsa -in server.key -out server.key.insecure
[email protected]:~$ mv server.key
[email protected]:~$ mv server.key.insecure server.key
[email protected]:~$ openssl req -new -key server.key -out server.csr
[email protected]:~$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
[email protected]:~$ sudo cp server.crt /etc/ssl/certs
[email protected]:~$ sudo cp server.key /etc/ssl/private

Step 7 » Now configure certificate path
[email protected]:~$ sudo postconf -e 'smtpd_tls_key_file = /etc/ssl/private/server.key'
[email protected]:~$ sudo postconf -e 'smtpd_tls_cert_file = /etc/ssl/certs/server.crt'

Step 8 » Open /etc/postfix/ file and uncomment below lines to enable smtps ( 465 ) and submission ( 587 ) .