Setup mail server on ubuntu 14.
04
Step 1 » Assign static IP and hostname and add a host entry for the host name .
Assign hostname in /etc/hostname
ktc@ktc-77:~$ sudo gedit /etc/hostname
Add a hostentry in /etc/hosts
root@ktc-77:/etc# sudo gedit hosts
Step 2 » Update the repositories.
root@ktc-77:/etc# 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.
Step 4 » After installation issue the below command to configure postfix.
root@ktc-77:/etc# sudo dpkg-reconfigure postfix
\
Step 5 » Now configure Postfix for SMTP-AUTH using Dovecot SASL by adding the below lines
to postfix config file /etc/postfix/main.cf .
ktc@mail:~$ sudo -i
[sudo] password for ktc:
root@mail:~# gedit /etc/postfix/main.cf
Step 6 » Now generate a digital certificate for tls. Issue the commands one by one and provide
details as per your domain.
root@mail:~# openssl genrsa -des3 -out server.key 2048
root@mail:~# openssl rsa -in server.key -out server.key.insecure
root@mail:~# mv server.key server.key.secure
root@mail:~# mv server.key.insecure server.key
root@mail:~# openssl req -new -key server.key -out server.csr
root@mail:~# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
root@mail:~# sudo cp server.crt /etc/ssl/certs
root@mail:~# sudo cp server.key /etc/ssl/private
Step 7 » Now configure certificate path
root@mail:~# sudo postconf -e 'smtpd_tls_key_file = /etc/ssl/private/server.key'
root@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 ) .
Step 9 » Now install Dovecot SASL by typing the below command.
root@mail:~# sudo apt-get install dovecot-common
Issue the following values for the prompts during installation.
1. yes
2. mail.abdulla.com
Step 10 » Make changes to the files as follows.
Open /etc/dovecot/conf.d/10-master.conf file and find # Postfix smtp-auth line ( line no:95 ) and
add the below lines .
Open /etc/dovecot/conf.d/10-auth.conf file and find (line no:100)
auth_mechanisms = plain and replace auth_mechanisms = plain login
Step 11 » Restart postfix and dovecot services
root@mail:~# sudo service postfix restart
root@mail:~# sudo service dovecot restart
Step 12 » Now test SMTP-AUTH and smtp/pop3 port access .
Type the below command and should get below response.
Step 12 » Install dovecot using the below command
Step 13 » Now configure mailbox. Open /etc/dovecot/conf.d/10-mail.conf file and find (Line
no:30 )
mail_location = mbox:~/mail:INBOX=/var/mail/%u
Replace with
mail_location = maildir:~/Maildir
ktc@mail:~$ gedit /etc/dovecot/conf.d/10-mail.conf
Step 14 » Now change pop3_uidl_format . Open /etc/dovecot/conf.d/20-pop3.conf file and find
and uncomment the below line ( Line no : 50 )
root@mail:~# gedit /etc/dovecot/conf.d/20-pop3.conf
Step 15 » Now enable SSL . Open /etc/dovecot/conf.d/10-ssl.conf file and find and uncomment the
below line ( Line no : 6 )
ssl = yes
root@mail:~# gedit /etc/dovecot/conf.d/10-ssl.conf
Step 16 »Restart dovecot service.
root@mail:~# sudo service dovecot restart
Step 17 » Now test pop3 and imap port access using the telnet command.
root@mail:~# telnet mail.abdulla.com 110
OR check for listening ports using netstat command .
Step 18 » Create some users and check using mail clients like thunderbird or outlook
root@mail:~# sudo useradd -m abdulla -s /sbin/nologin
root@mail:~# sudo passwd abdulla
» Installing and configuring squirrelmail:
Step 19 » Install squirrelmail using the below command. This will install apache and PHP
packages.
root@mail:~# sudo apt-get install squirrelmail
Step 20 » Configure squirrelmail
root@mail:~# sudo squirrelmail-configure
Everything is pre-configured , we just need to change Organization name .
» Press 1 (Organization Preferences) » again press 1 (Organization Name) » Organization Name »
Press S » Press Q to quit
Step 19 » Now configure apache to enable squirrelmail .
root@mail:~# sudo cp /etc/squirrelmail/apache.conf /etc/apache2/sites-available/squirrelmail.conf
root@mail:~# sudo a2ensite squirrelmail
Step 20 » Restart Apache service
root@mail:~# sudo service apache2 restart
Step 21 » Now open http://serverIP/squirrelmail in your browser and login using username
(bobby) . you can send and receive mail using squirrelmail.
Okay .. its over now ..