main.cf<\/code> file:<\/p>\npostconf -e \"myhostname = $(hostname -f)\"\r\n \r\npostconf -e \"virtual_mailbox_domains = proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_domains_maps.cf\"\r\npostconf -e \"virtual_alias_maps = proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_alias_maps.cf, proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_alias_domain_maps.cf, proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_alias_domain_catchall_maps.cf\"\r\npostconf -e \"virtual_mailbox_maps = proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_mailbox_maps.cf, proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_alias_domain_mailbox_maps.cf\"\r\n \r\npostconf -e \"smtpd_tls_cert_file = \/etc\/pki\/tls\/certs\/localhost.crt\"\r\npostconf -e \"smtpd_tls_key_file = \/etc\/pki\/tls\/private\/localhost.key\"\r\npostconf -e \"smtpd_use_tls = yes\"\r\npostconf -e \"smtpd_tls_auth_only = yes\"\r\n \r\npostconf -e \"smtpd_sasl_type = dovecot\"\r\npostconf -e \"smtpd_sasl_path = private\/auth\"\r\npostconf -e \"smtpd_sasl_auth_enable = yes\"\r\npostconf -e \"smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination\"\r\n \r\npostconf -e \"mydestination = localhost\"\r\npostconf -e \"mynetworks = 127.0.0.0\/8\"\r\npostconf -e \"inet_protocols = ipv4\"\r\npostconf -e \"inet_interfaces = all\"\r\n\r\npostconf -e \"virtual_transport = lmtp:unix:private\/dovecot-lmtp\"\r\n<\/pre>\nOpen the master.cf<\/code> file, find submission inet n<\/code> and smtps inet n<\/code> sections and edit as follows:<\/p>\nnano \/etc\/postfix\/master.cf<\/pre>\nsubmission inet n - n - - smtpd\r\n -o syslog_name=postfix\/submission\r\n -o smtpd_tls_security_level=encrypt\r\n -o smtpd_sasl_auth_enable=yes\r\n# -o smtpd_reject_unlisted_recipient=no\r\n# -o smtpd_client_restrictions=$mua_client_restrictions\r\n# -o smtpd_helo_restrictions=$mua_helo_restrictions\r\n# -o smtpd_sender_restrictions=$mua_sender_restrictions\r\n# -o smtpd_recipient_restrictions=\r\n -o smtpd_relay_restrictions=permit_sasl_authenticated,reject\r\n -o milter_macro_daemon_name=ORIGINATING\r\nsmtps inet n - n - - smtpd\r\n -o syslog_name=postfix\/smtps\r\n# -o smtpd_tls_wrappermode=yes\r\n -o smtpd_sasl_auth_enable=yes\r\n# -o smtpd_reject_unlisted_recipient=no\r\n# -o smtpd_client_restrictions=$mua_client_restrictions\r\n# -o smtpd_helo_restrictions=$mua_helo_restrictions\r\n# -o smtpd_sender_restrictions=$mua_sender_restrictions\r\n# -o smtpd_recipient_restrictions=\r\n -o smtpd_relay_restrictions=permit_sasl_authenticated,reject\r\n -o milter_macro_daemon_name=ORIGINATING\r\n\r\n<\/pre>\nEnable the postfix service<\/p>\n
systemctl enable postfix\r\nsystemctl restart postfix\r\n<\/pre>\n<\/span>7. Install and Configure Dovecot<\/span><\/h2>\nInstall dovecot with MySQL support using the command bellow:<\/p>\n
yum install dovecot dovecot-mysql<\/pre>\nOpen the \/etc\/dovecot\/conf.d\/10-mail.conf<\/code> file and change the following values:<\/p>\nnano \/etc\/dovecot\/conf.d\/10-mail.conf<\/code><\/pre>\nmail_location = maildir:\/var\/vmail\/%d\/%n\r\nmail_privileged_group = mail\r\nmail_uid = vmail\r\nmail_gid = mail\r\nfirst_valid_uid = 150\r\nlast_valid_uid = 150\r\n<\/pre>\nOpen the \/etc\/dovecot\/conf.d\/10-auth.conf<\/code> file and change the following values:<\/p>\nnano \/etc\/dovecot\/conf.d\/10-auth.conf<\/code><\/pre>\nauth_mechanisms = plain login\r\n#!include auth-system.conf.ext\r\n!include auth-sql.conf.ext\r\n<\/pre>\nCreate a new dovecot-sql.conf.ext<\/code> file:<\/p>\nnano \/etc\/dovecot\/dovecot-sql.conf.ext<\/pre>\ndriver = mysql\r\nconnect = host=localhost dbname=postfixadmin user=postfixadmin password=strong_password\r\ndefault_pass_scheme = MD5-CRYPT\r\npassword_query = SELECT username as user, password, '\/var\/vmail\/%d\/%n' as userdb_home, 'maildir:\/var\/vmail\/%d\/%n' as userdb_mail, 150 as userdb_uid, 8 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'\r\nuser_query = SELECT '\/var\/vmail\/%d\/%u' as home, 'maildir:\/var\/vmail\/%d\/%u' as mail, 150 AS uid, 8 AS gid, concat('dirsize:storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1'\r\n<\/pre>\nIn the \/etc\/dovecot\/conf.d\/10-ssl.conf<\/code> file enable SSL support:<\/p>\nssl = yes<\/pre>\nOpen the \/etc\/dovecot\/conf.d\/15-lda.conf<\/code> file and set the postmaster_address<\/code> email address.<\/p>\npostmaster_address = postmaster@your_domain_name.com<\/pre>\nOpen the \/etc\/dovecot\/conf.d\/10-master.conf<\/code> file, find the service lmtp section and change it to:<\/p>\nservice lmtp {\r\n unix_listener \/var\/spool\/postfix\/private\/dovecot-lmtp {\r\n mode = 0600\r\n user = postfix\r\n group = postfix\r\n }\r\n}\r\n<\/pre>\nfind the service auth section and change it to:<\/p>\n
service auth {\r\n unix_listener \/var\/spool\/postfix\/private\/auth {\r\n mode = 0666\r\n user = postfix\r\n group = postfix\r\n }\r\n unix_listener auth-userdb {\r\n mode = 0600\r\n user = vmail\r\n #group = vmail\r\n }\r\n user = dovecot\r\n}\r\n<\/pre>\nChange the service auth-worker section to the following:<\/p>\n
service auth-worker {\r\n user = vmail\r\n}<\/pre>\nSet the permissions:<\/p>\n
chown -R vmail:dovecot \/etc\/dovecot\r\nchmod -R o-rwx \/etc\/dovecot<\/pre>\nEnable and restart the dovecot service<\/p>\n
systemctl enable dovecot \r\nsystemctl restart dovecot \r\n<\/pre>\n