Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":2586,"date":"2019-12-06T14:43:37","date_gmt":"2019-12-06T14:43:37","guid":{"rendered":"https:\/\/support.aklwebhost.com\/?post_type=manual_kb&p=2586"},"modified":"2019-12-11T00:43:12","modified_gmt":"2019-12-11T00:43:12","slug":"simple-mailserver-with-postfix-dovecot-and-sieve-on-centos-7","status":"publish","type":"manual_kb","link":"https:\/\/support.aklwebhost.com\/knowledgebase\/simple-mailserver-with-postfix-dovecot-and-sieve-on-centos-7\/","title":{"rendered":"Simple Mailserver With Postfix, Dovecot, And Sieve On CentOS 7"},"content":{"rendered":"

This tutorial will show you how to get a simple mailserver on CentOS 7<\/strong>, with\u00a0Postfix as MTA<\/strong>,\u00a0Dovecot as MDA<\/strong>\u00a0and Sieve for sorting mail – all over an encrypted connection for improved security.<\/p>\n

In\u00a0order to configure everything<\/strong>, you will first need to\u00a0install these packages<\/strong>:<\/p>\n

yum install postfix dovecot dovecot-pigeonhole mailx\r\n<\/code><\/pre>\n

The\u00a0first configuration step<\/strong>\u00a0is done in\u00a0\/etc\/dovecot\/conf.d\/15-lda.conf<\/code>, by adding a postmaster address.\u00a0This allows people to contact you in case of a failure.<\/strong>\u00a0We will also be allowing\u00a0auto-creation<\/strong>\u00a0of folders and\u00a0auto-subscription<\/strong>\u00a0of said folders to avoid an inconsistent state between your mail client and the server:<\/p>\n

postmaster_address = yourname@yourdomain.tld\r\nlda_mailbox_autocreate = yes\r\nlda_mailbox_autosubscribe = yes\r\n<\/code><\/pre>\n

The next step is to assign the correct path for your users’ mailboxes in<\/strong>\u00a0\/etc\/dovecot\/conf.d\/10-mail.conf<\/code>:<\/p>\n

mail_location = maildir:~\/Maildir\r\n<\/code><\/pre>\n

Make sure that there is only one mention of “mail_location<\/strong>” in the file to avoid problems. The last step for ensuring\u00a0basic functionality is to tell Postfix to deliver the mails via Dovecot<\/strong>. Add the following line to\u00a0\/etc\/postfix\/main.cf<\/code>:<\/p>\n

mailbox_command = \/usr\/libexec\/dovecot\/deliver\r\n<\/code><\/pre>\n

Restart both services and you can send the first test mail:<\/strong><\/p>\n

systemctl restart postfix\r\nsystemctl restart dovecot\r\n<\/code><\/pre>\n

Since it is considered rude to use the root-account for mailing, you should create a separate user for your mailing needs:<\/strong><\/p>\n

 useradd -m youruser\r\n passwd youruser\r\n<\/code><\/pre>\n

Now, you can test the mail functionality with the following command:<\/strong><\/p>\n

echo \"TEST\" | mail -s \"testmail\" youruser@localhost && tail -f \/var\/log\/maillog\r\n<\/code><\/pre>\n

If your\u00a0log files contain a line similar to the following one<\/strong>\u00a0(The last part is the important) ..<\/p>\n

postfix\/local[27114]: 3F63C5B71: to=<youruser@localhost>, orig_to=<youruser@localhost>, relay=local, delay=0.01, delays=0\/0\/0\/0.01, dsn=2.0.0, status=sent (delivered to command: \/usr\/libexec\/dovecot\/deliver)\r\n<\/code><\/pre>\n

..\u00a0then everything is working properly.<\/strong><\/p>\n

At this point,\u00a0there are two important things missing – encryption and mail sorting.<\/strong><\/p>\n

The\u00a0first can be configured, for Dovecot<\/strong>, in\u00a0\/etc\/dovecot\/conf.d\/10-ssl.conf<\/code>,\u00a0assuming you already have a certificate at hand:<\/strong><\/p>\n

ssl = require\r\nssl_cert = <\/path\/to\/your\/certificate\r\nssl_key = <\/path\/to\/your\/key\r\n<\/code><\/pre>\n

For\u00a0sieve to work<\/strong>, edit the\u00a0protocol<\/strong>\u00a0section in\u00a0\/etc\/dovecot\/conf.d\/15-lda.conf<\/code>\u00a0to look like this:<\/p>\n

protocol lda {\r\n  mail_plugins = $mail_plugins sieve\r\n}\r\n<\/code><\/pre>\n

Restart the service:<\/strong><\/p>\n

systemctl restart dovecot\r\n<\/code><\/pre>\n

And\u00a0that’s it.<\/strong>\u00a0You can now log in via\u00a0IMAP or POP3<\/strong>\u00a0in a secure way, send transport encrypted mails, and write filters with Sieve.<\/p>\n

It is also important to allow the\u00a0IMAP, SMTP, and POP3<\/strong>\u00a0ports in firewalld as follows<\/p>\n

firewall-cmd --permanent --add-service=smtp\r\nfirewall-cmd --permanent --add-service=pop3\r\nfirewall-cmd --permanent --add-service=imap\r\nfirewall-cmd --permanent --add-service=smtps\r\nfirewall-cmd --permanent --add-service=pop3s\r\nfirewall-cmd --permanent --add-service=imaps\r\nfirewall-cmd --reload<\/code><\/pre>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[231,244],"manual_kb_tag":[306,307,360],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2586"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2586"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2586\/revisions"}],"predecessor-version":[{"id":2587,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2586\/revisions\/2587"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2586"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2586"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}