Postfix and Dovecot Configuration
Installation
hostnamectl set-hostname mail.<domain>.<tld>yum -y install postfix dovecot
Postfix Configuration
-
Append the following to
/etc/postfix/main.cf:myhostname = mail.<domain>.<tld>mydomain = <domain>.<tld>myorigin = $mydomainhome_mailbox = mail/mynetworks = 127.0.0.0/8 <domain IP>inet_interfaces = allmydestination = $myhostname, localhost.$mydomain, localhost, $mydomainsmtpd_sasl_type = dovecotsmtpd_sasl_path = private/authsmtpd_sasl_local_domain =smtpd_sasl_security_options = noanonymousbroken_sasl_auth_clients = yessmtpd_sasl_auth_enable = yessmtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destinationsmtp_tls_security_level = maysmtpd_tls_security_level = maysmtp_tls_note_starttls_offer = yessmtpd_tls_loglevel = 1smtpd_tls_key_file = /etc/letsencrypt/live/<domain>.<tld>/privkey.pemsmtpd_tls_cert_file = /etc/letsencrypt/live/<domain>.<tld>/fullchain.pemsmtpd_tls_received_header = yessmtpd_tls_session_cache_timeout = 3600ssmtpd_use_tls=yestls_random_source = dev:/dev/urandomvirtual_alias_domains = <domain>.<tld>virtual_alias_maps = hash:/etc/postfix/virtual
-
Find and uncomment the following lines in
/etc/postfix/main.cf:#inet_interfaces = localhost#mydestination = $myhostname, localhost.$mydomain, localhost
-
Append the following lines to
/etc/postfix/master.cf:submission inet n - n - - smtpd-o syslog_name=postfix/submission-o smtpd_sasl_auth_enable=yes-o smtpd_recipient_restrictions=permit_sasl_authenticated,reject_unauth_destination-o milter_macro_daemon_name=ORIGINATINGsmtps inet n - n - - smtpd-o syslog_name=postfix/smtps-o smtpd_sasl_auth_enable=yes-o smtpd_recipient_restrictions=permit_sasl_authenticated,reject_unauth_destination-o milter_macro_daemon_name=ORIGINATING
-
Make sure that the following is present in
/etc/postfix/main.cf:alias_maps = hash:/etc/aliases
-
Edit and add the desired email address to
/etc/postfix/virtualsuch as the following:info@<domain>.<tld> adminwebmaster@<domain>.<tld> admin
-
Create a map database:
postmap /etc/postfix/virtual
Dovecot Configuration
-
Find and modify the following lines in
/etc/dovecot/conf.d/10-master.conf:# Postfix smtp-authunix_listener /var/spool/postfix/private/auth {mode = 0660user = postfixgroup = postfix}
-
Find and modify the following lines in
/etc/dovecot/conf.d/10-auth.conf:auth_mechanisms = plain login
-
Find and modify the following lines in
/etc/dovecot/conf.d/10-mail.conf:mail_location = maildir:~/mail
-
Find and modify the following lines in
/etc/dovecot/conf.d/20-pop3.conf:pop3_uidl_format = %08Xu%08Xv
-
Find and modify the following lines in
/etc/dovecot/conf.d/10-ssl.conf:ssl_cert = </etc/letsencrypt/live/<domain>.<tld>/fullchain.pemssl_key = </etc/letsencrypt/live/<domain>.<tld>/privkey.pem
Restart and Enable Services
systemctl restart postfixsystemctl enable postfixsystemctl restart dovecotsystemctl enable dovecot
Open Firewall Ports
firewall-cmd --permanent --add-service=smtpfirewall-cmd --permanent --add-port=587/tcpfirewall-cmd --permanent --add-port=465/tcpfirewall-cmd --permanent --add-port=110/tcpfirewall-cmd --permanent --add-service=pop3sfirewall-cmd --permanent --add-port=143/tcpfirewall-cmd --permanent --add-service=imapsfirewall-cmd --reload
Configure DNS
-
Add an
Arecord for the mail server:name = mail.<domain>.<tld>`IP = <mail server IP>
-
Add an
MXrecord:Hostname = mail.<domain>.<tld>Priority = 5
-
Add the following
TXTrecords:Name = @Text = "v=spf1 ip4:<domain IP> ~all"Name = _dmarc.<domain>.<tld>Text = v=DMARC1; p=none
-
Add
PTRrecord for<domain>.<tld> -
Finally, test your email at
https://www.mail-tester.com/
Notes on Using Let's Encrypt for SSL
Make sure that Encryption is set to STARTTLS when configuring mail clients
No Comments