0% found this document useful (0 votes)
53 views20 pages

LPI102 - Lesson11 - Setting Up Email Server

This document provides instructions for setting up a mail server on a Linux system. It describes installing and configuring Postfix as the SMTP server, Dovecot for POP3 and IMAP services, and securing communication with SSL. Key steps include generating SSL certificates, configuring Postfix and Dovecot, testing services, allowing ports through the firewall, and installing a mail client.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views20 pages

LPI102 - Lesson11 - Setting Up Email Server

This document provides instructions for setting up a mail server on a Linux system. It describes installing and configuring Postfix as the SMTP server, Dovecot for POP3 and IMAP services, and securing communication with SSL. Key steps include generating SSL certificates, configuring Postfix and Dovecot, testing services, allowing ports through the firewall, and installing a mail client.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

LPI102 - Network Administration

Lesson 11 – Setting Up Mail Server


Objectives

• Understanding SMTP, POP, IMAP


• Setting up a SMTP Server with Postfix
• Installing and configuring Dovecot
• Installing and configuring Squirrelmail
What is a Mail Server?
• A mail server is equivalent of your friendly neighborhood
mailman. Every email that is sent passes through a series of
mail servers along its way to its intended recipient.
• Mail servers can be broken down into two main categories:
outgoing mail servers and incoming mail servers.
– Outgoing mail servers are known as SMTP, or Simple Mail
Transfer Protocol, servers.
– Incoming mail servers come in two main varieties.
• POP3, or Post Office Protocol, version 3, servers are best known for
storing sent and received messages on PCs' local hard drives.
• IMAP, or Internet Message Access Protocol, servers always store copies
of messages on servers.
How Email Works
• When an email is sent, the message is routed from server to
server, the message is sent to the mail server tasked with
transporting emails (called the MTA or Mail Transport Agent)
to the recipient's MTA.
• The recipient's MTA then delivers the email to the incoming
mail server (called the MDA, for Mail Delivery Agent), which
stores the email as it waits for the user to accept it.
Configuring DNS Server
1. Add MX record in [Link] file:
#vim /var/named/[Link]
$TTL 86400
@ IN SOA [Link]. [Link]. (
2016042112 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
43200 ;Minimum TTL)
IN NS [Link]. ;Name Server Information
IN MX 10 [Link]. ;Mail Exchanger record
svr2 IN A [Link] ;A - Hostname to IP Address
www IN CNAME [Link]. ;CNAME record
mail IN CNAME [Link]. ;CNAME record
Installing Mail Server
1. Install postfix package:
# yum install -y --disablerepo=* --enablerepo=Local postfix*
2. Configure Postfix:
vim /etc/postfix/[Link]

myhostname = [Link] #Line 76 - Set FQDN
mydomain = [Link] #Line 83 - Set domain name
myorigin = $mydomain #Line 99 - Uncomment
inet_interfaces = all #Line 116 - Change to all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain #Line
164 - Add $mydomain
mynetworks = [Link]/24 #Line 264 - Add local networks
home_mailbox = Maildir/ #Line 419 - Uncomment
Installing Mail Server
3. Start and enable Postfix service:
#systemctl start postfix
#systemctl enable postfix
4. Create new users:
#useradd nv1
#useradd nv2
#passwd nv1
#passwd nv2
(*): Logon system with nv1, nv2 to automatically create their home
profiles.
Installing Mail Server
5. Test SMTP server:
#telnet localhost smtp

ehlo localhost #Begin composing email
mail from: nv1 #Mail sender address
rcpt to: nv2 #Mail receiver address
data #Body of email
. #Complete body of email
quit #Exit smtp connection
6. Read nv2 email in SMTP server:
#cd /home/nv2/Maildir/new/
#cat <email>
Installing Mail Server
7. Install Dovecot:
#yum install -y --disablerepo=* --enablerepo=Local dovecot*
8. Configure Dovecot:
Edit file /etc/dovecot/[Link] file
#vim /etc/dovecot/[Link]
 protocols = imap pop3 lmtp #Line 24 - Uncomment

Edit file /etc/dovecot/conf.d/[Link] file


#vim /etc/dovecot/conf.d/[Link]
 mail_location = maildir:~/Maildir #Line 24 - Uncomment
Installing Mail Server
8. Configure Dovecot (cont.):
Edit /etc/dovecot/conf.d/[Link]
#vim /etc/dovecot/conf.d/[Link]

disable_plaintext_auth = yes #Line 10 - uncomment
auth_mechanisms = plain login #Line 100 - Add "login"

Edit file /etc/dovecot/conf.d/[Link],


#vim /etc/dovecot/conf.d/[Link]

user = postfix #Line 91 - Uncomment and add "postfix"
group = postfix #Line 92 - Uncomment and add "postfix"
Installing Mail Server
9. Start and enable Dovecot service:
#systemctl enable dovecot
#systemctl start dovecot
10. Test Dovecot service:
#telnet localhost pop3
user nv2 #Enter the receive mail user name
pass 123 #Enter the password
list #List user email
retr 1 #Type the ordinary number of email to view mail
quit #Type 'quit' to exit
11. Disable selinux:
#vim /etc/sysconfig/selinux
 SELINUX=disabled
Installing Mail Server
12. Allow access to the email services from external systems:
# firewall-cmd --zone=public --permanent --add-port=25/tcp
# firewall-cmd --zone=public --permanent --add-port=465/tcp
# firewall-cmd --zone=public --permanent --add-port=110/tcp
# firewall-cmd --zone=public --permanent --add-port=995/tcp
# firewall-cmd --zone=public --permanent --add-port=587/tcp
# firewall-cmd --zone=public --permanent --add-port=143/tcp
# firewall-cmd --zone=public --permanent --add-port=993/tcp
# firewall-cmd --zone=public --permanent --add-service=smtp
# firewall-cmd --zone=public --permanent --add-service=pop3s
# firewall-cmd --zone=public --permanent --add-service=imaps
# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --reload
Installing Mail Server
13. Install Evolution mail client:
#yum install -y --disablerepo=* --enablerepo=Local evolution
14. Configure account:
Installing Mail Server
14. Configure account (cont.):
Installing Mail Server
14. Configure account (cont.):
Securing SMTP Server with SSL
1. Install SSL:
# yum install -y --disablerepo=* --enablerepo=Local mod_ssl openssl
2. Generate a private key [Link] with 2048-bit encryption:
# openssl genrsa -out [Link] 2048
3. Generate a certificate signing request [Link]:
# openssl req -new -key [Link] -out [Link]
4. Generate a self-sign certificate [Link] of X509 type:
# openssl req -x509 -days 365 -in [Link] -key [Link] -out [Link]
5. Move ca.* files to the expected directories:
# mv [Link] /etc/pki/tls/certs/
# mv [Link] /etc/pki/tls/private/
# mv [Link] /etc/pki/tls/private/
Securing SMTP Server with SSL
6. Edit Postfix [Link] file:
#vim /etc/postfix/[Link]
 Uncomment line 16 to 25
submission inet n - n - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_reject_unlisted_recipient=no
-o smtpd_client_restrictions=$mua_client_restrictions
-o smtpd_helo_restrictions=$mua_helo_restrictions
-o smtpd_sender_restrictions=$mua_sender_restrictions
-o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
Securing SMTP Server with SSL
7. Edit Postfix [Link] file:
#vim /etc/postfix/[Link]
 add the following lines to the end of the file:
smtpd_tls_key_file = /etc/pki/tls/private/[Link]
smtpd_tls_cert_file = /etc/pki/tls/certs/[Link]
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_tls_security_level=may

You might also like