{"id":88,"date":"2017-05-10T10:59:28","date_gmt":"2017-05-10T10:59:28","guid":{"rendered":"https:\/\/d1m0.com\/?p=88"},"modified":"2017-08-26T09:51:02","modified_gmt":"2017-08-26T09:51:02","slug":"centos-7-postfix-postfix-admin-dovecot-mysql","status":"publish","type":"post","link":"https:\/\/d1m0.com\/?p=88","title":{"rendered":"Centos 7 + postfix +postfix admin + dovecot + mysql"},"content":{"rendered":"<p>useradd -g vmail -u 5000 vmail -d \/home\/vmail -m<\/p>\n<blockquote><p>yum install dovecot dovecot-mysql\u00a0 postfix mariadb\u00a0 mariadb-server php php-imap php-mbstring php-pdo php-mysql php-fpm (optional postfix-perl-scripts)<\/p><\/blockquote>\n<p>secure mysql installation<\/p>\n<blockquote><p>mysql_secure_installation<\/p><\/blockquote>\n<p>mysql &#8211;<\/p>\n<blockquote><p>CREATE DATABASE postfix;<\/p>\n<p>CREATE USER &#8216;postfix&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;shibaniakus&#8217;;<\/p>\n<p>GRANT ALL PRIVILEGES ON `postfix` . * TO &#8216;postfix&#8217;@&#8217;localhost&#8217;;<\/p><\/blockquote>\n<p>\/\/ Postfix \/\/<\/p>\n<p>vim \/etc\/postfix\/main.cf<\/p>\n<blockquote><p>virtual_uid_maps = static:5000<br \/>\nvirtual_gid_maps = static:5000<br \/>\nvirtual_mailbox_base = \/home\/vmail<br \/>\nvirtual_mailbox_domains = mysql:\/etc\/postfix\/mysql_virtual_mailbox_domains.cf<br \/>\nvirtual_mailbox_maps = mysql:\/etc\/postfix\/mysql_virtual_mailbox_maps.cf,mysql:\/etc\/postfix\/mysql_virtual_alias_domains_maps.cf<br \/>\nvirtual_alias_maps = mysql:\/etc\/postfix\/mysql_virtual_alias_maps.cf, mysql:\/etc\/postfix\/mysql_virtual_alias_domains_maps.cf<br \/>\nrelay_domains = mysql:\/etc\/postfix\/mysql_relay_domains.cf<br \/>\nsmtpd_recipient_restrictions =<br \/>\npermit_mynetworks,<br \/>\npermit_sasl_authenticated,<\/p>\n<p>reject_non_fqdn_hostname,<\/p><\/blockquote>\n<p><!--more--><\/p>\n<blockquote><p>reject_non_fqdn_sender,<br \/>\nreject_non_fqdn_recipient,<br \/>\nreject_unauth_destination,<br \/>\nreject_unauth_pipelining,<br \/>\nreject_invalid_hostname<br \/>\nsmtpd_sasl_auth_enable = yes<br \/>\nsmtpd_sasl_security_options = noanonymous<br \/>\nmynetworks = 192.168.3.0\/24 ,\u00a0 more networks<br \/>\nsmtpd_discard_ehlo_keywords = silent-discard, dsn<br \/>\nsmtpd_banner = $myhostname ESMTP<br \/>\nappend_dot_mydomain = no<br \/>\nappend_at_myorigin = nosmtpd_tls_security_level = may<br \/>\nsmtp_tls_security_level = may<\/p>\n<p>smtpd_tls_auth_only = yes<\/p>\n<p>smtpd_tls_received_header = yes<br \/>\nmyhostname = mail.d1m0.com<br \/>\nsmtpd_tls_cert_file = \/etc\/pki\/dovecot\/2_mail.d1m0.com.crt<br \/>\nsmtpd_tls_key_file = \/etc\/pki\/dovecot\/mail.key<br \/>\nbiff = no<br \/>\nmessage_size_limit = 4194304<br \/>\ndovecot_destination_recipient_limit = 1<br \/>\nsmtpd_tls_CAfile = \/etc\/pki\/dovecot\/1_root_bundle.crt<br \/>\nsmtp_tls_CAfile = $smtpd_tls_CAfile<\/p>\n<p>smtpd_tls_loglevel = 1<br \/>\nsmtp_tls_loglevel = 1<br \/>\nsmtpd_sasl_path = private\/auth<br \/>\nsmtpd_sasl_type = dovecot<br \/>\nsmtpd_soft_error_limit = 1h<\/p><\/blockquote>\n<p>vim mysql_virtual_mailbox_maps.cf<\/p>\n<blockquote><p>hosts = 127.0.0.1<br \/>\nuser = postfix<br \/>\npassword = @@<br \/>\ndbname = postfix<br \/>\nquery = SELECT maildir FROM mailbox WHERE username=&#8217;%s&#8217; AND active = 1<\/p><\/blockquote>\n<p>vim mysql_virtual_mailbox_domains.cf<\/p>\n<blockquote><p>hosts = 127.0.0.1<br \/>\nuser = postfix<br \/>\npassword = @@<br \/>\ndbname = postfix<br \/>\nquery = SELECT domain FROM domain WHERE domain=&#8217;%s&#8217; and backupmx = 0 and active = 1<\/p><\/blockquote>\n<p>vim mysql_virtual_alias_maps.cf<\/p>\n<blockquote><p>password = @@<br \/>\ndbname = postfix<br \/>\nquery = SELECT goto FROM alias WHERE address=&#8217;%s&#8217; AND active = 1<\/p><\/blockquote>\n<p>vim mysql_virtual_alias_domains_maps.cf<\/p>\n<blockquote><p>hosts = 127.0.0.1<br \/>\nuser = postfix<br \/>\npassword = @@<br \/>\ndbname = postfix<br \/>\nquery = select goto from alias,alias_domain where alias_domain.alias_domain=&#8217;%d&#8217; and alias.address = &#8216;%u&#8217; || &#8216;@&#8217; || alias_domain.target_domain and alias.active= true and alias_domain.active= 1<\/p><\/blockquote>\n<p>\/\/ Dovecot \/\/<\/p>\n<p>vim \/etc\/dovecot\/dovecot.conf<\/p>\n<blockquote><p>listen = *<br \/>\nssl = yes<br \/>\nssl_cert = &lt;\/etc\/pki\/dovecot\/2_mail.crt<br \/>\nssl_key = &lt;\/etc\/pki\/dovecot\/mail.key<br \/>\nssl_ca = &lt;\/etc\/pki\/dovecot\/1_root_bundle.crt<br \/>\nprotocols = imap lmtp<br \/>\ndisable_plaintext_auth = no<br \/>\nauth_mechanisms = plain login<br \/>\nmail_access_groups = vmail<br \/>\ndefault_login_user = vmail<br \/>\nfirst_valid_uid = 2000<br \/>\nfirst_valid_gid = 5000<br \/>\nmail_location = maildir:\/home\/vmail\/%d\/%n<\/p>\n<p>userdb {<br \/>\ndriver = sql<br \/>\nargs = \/etc\/dovecot\/dovecot-sql.conf.ext<br \/>\n}<\/p>\n<p>passdb {<br \/>\ndriver = sql<br \/>\nargs = \/etc\/dovecot\/dovecot-sql.conf.ext<br \/>\n}<\/p>\n<p>service auth {<br \/>\nunix_listener auth-client {<br \/>\ngroup = postfix<br \/>\nmode = 0660<br \/>\nuser = postfix<br \/>\npath = \/var\/spool\/postfix\/private\/auth<br \/>\n}<br \/>\nuser = root<br \/>\n}<br \/>\nservice imap-login {<br \/>\nprocess_min_avail = 1<br \/>\nuser = vmail<br \/>\n}<\/p><\/blockquote>\n<p>vim \/etc\/dovecot\/dovecot-sql.conf.ext<\/p>\n<blockquote><p>connect = host=127.0.0.1 dbname=postfix user=postfix password=@@<br \/>\ndriver = mysql<br \/>\ndefault_pass_scheme = MD5-CRYPT<br \/>\npassword_query = SELECT username AS user,password FROM mailbox WHERE username = &#8216;%u&#8217; AND active=&#8217;1&#8242;<br \/>\nuser_query = SELECT maildir, 5000 AS uid, 5000 AS gid FROM mailbox WHERE username = &#8216;%u&#8217; AND active=&#8217;1&#8242;<br \/>\nuser_query = SELECT CONCAT(&#8216;\/home\/vmail\/&#8217;, maildir) AS home, 5000 AS uid, 5000 AS gid, CONCAT(&#8216;*:bytes=&#8217;, quota) AS quota_rule FROM mailbox WHERE username = &#8216;%u&#8217; AND active=&#8217;1&#8242;<br \/>\nuser_query = SELECT maildir, 5000 AS uid, 5000 AS gid, CONCAT(&#8216;dict:storage=&#8217;,floor(quota\/1000),&#8217; proxy::quota&#8217;) as quota FROM mailbox WHERE username = &#8216;%u&#8217; AND active=&#8217;1&#8242;<\/p><\/blockquote>\n<p>\/\/ Postfixadmin \/\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>useradd -g vmail -u 5000 vmail -d \/home\/vmail -m yum install dovecot dovecot-mysql\u00a0 postfix mariadb\u00a0 mariadb-server php php-imap php-mbstring php-pdo php-mysql php-fpm (optional postfix-perl-scripts) secure mysql installation mysql_secure_installation mysql &#8211; CREATE DATABASE postfix; CREATE USER &#8216;postfix&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;shibaniakus&#8217;; GRANT ALL PRIVILEGES ON `postfix` . * TO &#8216;postfix&#8217;@&#8217;localhost&#8217;; \/\/ Postfix \/\/ vim \/etc\/postfix\/main.cf virtual_uid_maps = &#8230;<\/p>\n<p><a href=\"https:\/\/d1m0.com\/?p=88\" class=\"more-link\">Continue reading &lsquo;Centos 7 + postfix +postfix admin + dovecot + mysql&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/d1m0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=88"}],"version-history":[{"count":10,"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":145,"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions\/145"}],"wp:attachment":[{"href":"https:\/\/d1m0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/d1m0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/d1m0.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}