Tuesday, February 6, 2018

Email Server in Ubuntu 14.04

For this setup I followed the youtube link given below so kudos to that guy.  The documentation is a bit poor.  However if you listed to that video then this becomes cake walk.  I have bolded all the command entered in the terminal.

Email server using ubuntu 14.04
https://www.youtube.com/watch?v=2pMC-6LVLLg

1. Vi /etc/hosts
127.0.1.1 mail.robert.com mail

2. vi /etc/hostname
mail

3. reboot

4. apt-get update -y; apt-get dist-upgrade -y

5. apt-get install postfix -y

Press enter twice, Internet site and

6. sudo dpkg-reconfigure postfix


* Let it be internet site
* Let it just be the main domain e.g. robert.com
* Other destinations to accept email for
mail.rober.com, localhost.robert.com, , localhost, robert.com
* Force sync update press no for that.
* Local network
Add up 10.10.10.0/24
* Put 0 for mailbox size limit.
* Leave + for local address extension character
* ipv4 for internet protocol.

Now we edit postfix

vi /etc/postfix/main.cf

home_mailbox = Maildir/
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain = robert.com
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject unknown client hostname
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

7. Certificates
$ openssl genrsa -des3 -out server.key 4096
enter and verify pass phrase

8.
$ openssl rsa -in server.key -out server.key.insecure
Enter and verify pass phrase

9. mv server.key server.key.secure
mv server.key.insecure server.key

openssl req -new -key server.key -out server.csr
For Common Name alone put robert.com

10.
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

sudo cp server.crt /etc/ssl/certs
sudo cp server.key /etc/ssl/private

sudo postconf -e 'smtpd_tls_key_file = /etc/ssl/private/server.key'
sudo postconf -e 'smtpd_tls_cert_file = /etc/ssl/certs/server.crt'

sudo nano /etc/postfix
we can see the key and cert file getting added up.

11. vi /etc/postfix/master.cf
uncomment
submission inet n
 -o syslog_name=postfix/submission
 -o smtpd_tls_security_level=encrypt
 -o smtpd_saslauth_enable=yes
 -o smtpd_relay_restictions=permit_sasl_authenticated,reject
 -o milter_macro_daemon_name=ORIGINATING

under smtps inet n - - - - smtpd
 -o syslog_name=postfix/smtps
 -o smtpd_tls_wrappermode=yes
 -o smtpd_sasl_auth_enable=yes

12. apt-get install dovcot-common -y
* Press Yes for self signed cert
* Host name as mail.robert.com and press okay.

vi /etc/dovecot/conf.d/10-master.conf

uncomment
unix_listener /var/spool/postfix/private/auth {
  mode = 0660
  user = postfix
  group = postfix
}

vi /etc/dovecot/conf.d/10-auth.conf
auth_mechanisms = plain login

sudo service postfix restart
sudo service dovecot restart

Both of these should connect
nc mail.robert.com 25
nc mail.robert.com 586

sudo apt-get install dovecot-imapd dovecot-pop3d -y

vi /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir

vi /etc/dovecot/conf.d/20-pop3.conf

Uncomment the line
pop3_uidl_format = %08Xu%08Xv

vi /etc/dovecot/conf.d/10-ssl.conf
uncomment the line
ssl = yes

sudo service dovecot restart


nc mail.robert.com 110
nc mail.robert.com 995
nc mail.robert.com 993
nc mail.robert.com 143



No comments:

Post a Comment