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
mail.itkylin.com

Add a hostentry in /etc/hosts
192.168.30.8 mail.itkylin.com
Step 2 » Update the repositories.
itkylin.com@mail:~$ 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.
itkylin.com@mail:~$ sudo apt-get install postfix
Step 4 » After installation issue the below command to configure postfix.

itkylin.com@mail:~$ sudo dpkg-reconfigure postfix

Now you will be prompted for set of details . choose the following values and replace itkylin.com.com with your domain name.
1. Internet Site
2. itkylin.com
3. itkylin
4. itkylin.com, localhost.localdomain, localhost
5. No
6. 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.0.0/24
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/main.cf .
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.
itkylin.com@mail:~$ openssl genrsa -des3 -out server.key 2048
itkylin.com@mail:~$ openssl rsa -in server.key -out server.key.insecure
itkylin.com@mail:~$ mv server.key server.key.secure
itkylin.com@mail:~$ mv server.key.insecure server.key
itkylin.com@mail:~$ openssl req -new -key server.key -out server.csr
itkylin.com@mail:~$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
itkylin.com@mail:~$ sudo cp server.crt /etc/ssl/certs
itkylin.com@mail:~$ sudo cp server.key /etc/ssl/private

Step 7 » Now configure certificate path
itkylin.com@mail:~$ sudo postconf -e 'smtpd_tls_key_file = /etc/ssl/private/server.key'
itkylin.com@mail:~$ sudo postconf -e 'smtpd_tls_cert_file = /etc/ssl/certs/server.crt'

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