Saturday 9 September 2017

Configure Mail Server & Setting up Mail Client: Fedora Linux 25

​Here, I would let you know how to configure mail server(MTA) and client(MUA) using evolution which is by default.

Environment: Fedora 25

​we will understand few components before we setup email configurations/settings

MUA(Mail User Agent) or Mail Client: Application used to write/send/read email messages.
e.g Evolution, KMail, Outlook etc.. text based mail clients like pine, mail ..etc 

MTA(Mail Transfer Agent):Transferring email messages from one computer to another(intranet or Internet). We would be configuring postfix in this section

MDA(Mail Delivery Agent): It will receive emails from the MTA and delivers them to relevant mailbox MUA(e.g Dovecot). There are few of the popular MDA which would remove unwanted email messages or spam before they reach MUA Inbox.(e.g Procmail ..etc )

SMTP(Simple Mail Transfer Protocol): communicates language that the MTA use to talk to each other and transfer message back and forth.

Architecture


Configuring MTA

Login as 'root' to perform below steps.
Note: SElinux was disabled.

- install postfix.
#dnf install postfix -y

-Take a backup copy of the file and copy paste below contents and change according to your infra setup.(lines marked in red)

#mv /etc/postfix/main.cf /etc/postfix/main.cf.original

# cat /etc/postfix/main.cf
     1  compatibility_level = 2
     2  queue_directory = /var/spool/postfix
     3  command_directory = /usr/sbin
     4  daemon_directory = /usr/libexec/postfix
     5  data_directory = /var/lib/postfix
     6  mail_owner = postfix
     7  myhostname = fedora.localhost.com
     8  mydomain = localhost.com
     9  myorigin = $mydomain
    10  inet_interfaces = $myhostname
    11  inet_protocols = ipv4
    12  mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
    13  unknown_local_recipient_reject_code = 550
    14  mynetworks = 192.168.122.0/24, 127.0.0.0/8, 10.0.0.0/24
    15  alias_maps = hash:/etc/aliases
    16  alias_database = hash:/etc/aliases
    17  smtpd_banner = $myhostname ESMTP
    18  debug_peer_level = 2
    19  debugger_command =
    20           PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
    21           ddd $daemon_directory/$process_name $process_id & sleep 5
    22  sendmail_path = /usr/sbin/sendmail.postfix
    23  newaliases_path = /usr/bin/newaliases.postfix
    24  mailq_path = /usr/bin/mailq.postfix
    25  setgid_group = postdrop
    26  html_directory = no
    27  manpage_directory = /usr/share/man
    28  sample_directory = /usr/share/doc/postfix/samples
    29  readme_directory = /usr/share/doc/postfix/README_FILES
    30  meta_directory = /etc/postfix
    31  shlib_directory = /usr/lib64/postfix
    32  message_size_limit = 10485760
    33  mailbox_size_limit = 1073741824
    34  smtpd_sasl_type = dovecot
    35  smtpd_sasl_path = private/auth
    36  smtpd_sasl_auth_enable = yes
    37  smtpd_sasl_security_options = noanonymous
    38  smtpd_sasl_local_domain = $myhostname
    39  smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject

- start service persistent after reboot 
# systemctl start postfix
# systemctl enable postfix

- If you had your firewall being running, add service 'smtp'. 
#firewall-cmd --add-service=smtp --permanent
#firewall-cmd --reload

Configuring MDA

- install dovecot
#dnf install dovecot -y

-Take a backup copy of the file and copy paste below contents and change according to your infra setup.(lines marked in red)

#mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.original
#mv /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf.original
#mv /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.original
#mv /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.original
#mv /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.original

# cat /etc/dovecot/dovecot.conf 
     1  protocols = imap pop3 lmtp
     2  listen = *,::
     3  dict {
     4  }
     5  !include conf.d/*.conf
     6  !include_try local.conf
#

# cat /etc/dovecot/conf.d/10-auth.conf
     1  disable_plaintext_auth = no
     2  auth_mechanisms = plain login
     3  !include auth-system.conf.ext
#

# cat /etc/dovecot/conf.d/10-mail.conf

     1  mail_location = maildir:~/Maildir
     2  namespace inbox {
     3    inbox = yes
     4  }
     5  protocol !indexer-worker {
     6  }
     7  mbox_write_locks = fcntl
#

# cat /etc/dovecot/conf.d/10-master.conf
     1   service imap-login {
     2    inet_listener imap {
     3    }
     4    inet_listener imaps {
     5    }
     6  }
     7  service pop3-login {
     8    inet_listener pop3 {
     9    }
    10    inet_listener pop3s {
    11    }
    12  }
    13  service lmtp {
    14    unix_listener lmtp {
    15    }
    16  }
    17  service imap {
    18  }
    19  service pop3 {
    20  }
    21  service auth {
    22    unix_listener auth-userdb {
    23  }
    24    unix_listener /var/spool/postfix/private/auth {
    25      mode = 0666
    26      user = postfix
    27      group = postfix
    28    }
    29  }
    30  service auth-worker {
    31  }
    32  service dict {
    33    unix_listener dict {
    34    }
    35  }
#

# cat /etc/dovecot/conf.d/10-ssl.conf
     1  ssl = required
     2  ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
     3  ssl_key = </etc/pki/dovecot/private/dovecot.pem
     4  ssl_cipher_list = PROFILE=SYSTEM
#

- start service persistent after reboot 
# systemctl start dovecot
# systemctl enable dovecot

- If you had your firewall being running, add service 'smtp'. 
#firewall-cmd --add-service={pop3,imap} --permanent
#firewall-cmd --reload

Configure MUA

Click on 'Evolution' and configure as per below ...

Edit -> Preferences -> Add ->Next  





Leave rest to default and continue to check [OK] .

Testing

Compose email and read yourself :)




Thanks

No comments:

Post a Comment