my dovecot.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
## Dovecot configuration file protocols = imap pop3 auth_mechanisms = plain passdb { driver = sql args = /etc/dovecot/dovecot-sql.conf } userdb sql { driver = sql args = /etc/dovecot/dovecot-sql.conf } service auth { unix_listener auth-client { group = postfix mode = 0660 user = postfix } user = root } mail_home = /home/vmail/%d/%u mail_location = maildir:~ ssl_cert = </etc/ssl/private/postfix.crt ssl_key = </etc/ssl/private/postfix.key listen = *, :: login_greeting = Dovecot ready. |
dovecot-sql.conf
1 2 3 4 5 6 7 8 9 10 |
driver = mysql connect = host=127.0.0.1 dbname=postfix_db user=postfix_user password=the_password # The new name for MD5 is MD5-CRYPT so you might need to change this depending on version default_pass_scheme = SHA512-CRYPT # Get the mailbox user_query = SELECT '/home/vmail/%d/%u' as home, 'maildir:/home/vmail/%d/%u' as mail, 5000 AS uid, 5000 AS gid, concat('dirsize:storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1' # Get the password password_query = SELECT username as user, password, '/home/vmail/%d/%u' as userdb_home, 'maildir:/home/vmail/%d/%u' as userdb_mail, 5000 as userdb_uid, 5000 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1' # If using client certificates for authentication, comment the above and uncomment the following #password_query = SELECT null AS password, ‘%u’ AS user |
postfix
main.cf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
queue_directory = /var/spool/postfix command_directory = /usr/bin daemon_directory = /usr/lib/postfix/bin data_directory = /var/lib/postfix mail_owner = postfix myhostname = the-fqdn-of-my-host mail.example.com mydomain = the base domain name example.com myorigin = $myhostname inet_interfaces = all unknown_local_recipient_reject_code = 550 mynetworks_style = host alias_maps = hash:/etc/postfix/aliases alias_database = $alias_maps smtpd_banner = $myhostname ESMTP $mail_name debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/bin/sendmail newaliases_path = /usr/bin/newaliases mailq_path = /usr/bin/mailq setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /etc/postfix/sample readme_directory = /usr/share/doc/postfix relay_domains = * virtual_alias_maps = proxy:mysql:/etc/postfix/virtual_alias_maps.cf virtual_mailbox_domains = proxy:mysql:/etc/postfix/virtual_domains_maps.cf virtual_mailbox_maps = proxy:mysql:/etc/postfix/virtual_mailbox_maps.cf virtual_mailbox_base = /home/vmail virtual_mailbox_limit = 512000000 virtual_minimum_uid = 5000 virtual_transport = virtual virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 local_transport = virtual local_recipient_maps = $virtual_mailbox_maps transport_maps = hash:/etc/postfix/transport smtpd_sasl_auth_enable = yes smtpd_sasl_type = dovecot smtpd_sasl_path = /var/run/dovecot/auth-client smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_recipient smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination #smtpd_sender_restrictions = permit_mynetworks, reject_sender_login_mismatch, permit_sasl_authenticated, reject_unknown_helo_hostname, reject_unknown_recipient_domain, reject_unknown_sender_domain smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_client_hostname #smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, check_client_access hash:/etc/postfix/rbl_override, reject_rbl_client zen.spamhaus.org, reject_unknown_client_hostname smtpd_sasl_security_options = noanonymous smtpd_sasl_tls_security_options = $smtpd_sasl_security_options smtpd_tls_auth_only = yes smtpd_tls_cert_file = /etc/ssl/private/postfix.crt smtpd_tls_key_file = /etc/ssl/private/postfix.key smtpd_sasl_local_domain = $mydomain broken_sasl_auth_clients = yes smtpd_tls_loglevel = 1 meta_directory = /etc/postfix |
master.cf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
smtp inet n - n - - smtpd submission inet n - n - - smtpd -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_reject_unlisted_recipient=no -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING smtps inet n - n - - smtpd -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING pickup unix n - n 60 1 pickup cleanup unix n - n - 0 cleanup qmgr unix n - n 300 1 qmgr tlsmgr unix - - n 1000? 1 tlsmgr rewrite unix - - n - - trivial-rewrite bounce unix - - n - 0 bounce defer unix - - n - 0 bounce trace unix - - n - 0 bounce verify unix - - n - 1 verify flush unix n - n 1000? 0 flush proxymap unix - - n - - proxymap proxywrite unix - - n - 1 proxymap smtp unix - - n - - smtp relay unix - - n - - smtp showq unix n - n - - showq error unix - - n - - error retry unix - - n - - error discard unix - - n - - discard local unix - n n - - local virtual unix - n n - - virtual lmtp unix - - n - - lmtp anvil unix - - n - 1 anvil scache unix - - n - 1 scache |
virtual_alias_maps.cf
1 2 3 4 5 |
user = postfix_user password = the pass wo rd hosts = 127.0.0.1 dbname = postfix_db query = SELECT goto FROM alias WHERE address='%s' AND active = true |
virtual_domains_maps.cf
1 2 3 4 5 |
user = postfix_user password = the pass wo rd hosts = 127.0.0.1 dbname = postfix_db query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = false AND active = true |
virtual_mailbox_limits.cf
1 2 3 4 5 |
user = postfix_user password = the pass word hosts = 127.0.0.1 dbname = postfix_db query = SELECT quota FROM mailbox WHERE username='%s' |
virtual_mailbox_maps.cf
1 2 3 4 5 |
user = postfix_user password = the pass word hosts = 127.0.0.1 dbname = postfix_db query = SELECT maildir FROM mailbox WHERE username='%s' AND active = true |
mysql
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
-- MySQL dump 10.13 Distrib 5.6.28-76.1, for Linux (x86_64) -- -- Host: 127.0.0.1 Database: postfix_db -- ------------------------------------------------------ -- Server version 5.6.28-76.1-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `admin` -- DROP TABLE IF EXISTS `admin`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `admin` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `super` tinyint(1) DEFAULT '0', `active` tinyint(1) DEFAULT '1', `created` datetime NOT NULL, `modified` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `alias` -- DROP TABLE IF EXISTS `alias`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `alias` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `address` varchar(255) DEFAULT NULL, `goto` text NOT NULL, `domain` varchar(255) NOT NULL, `active` tinyint(1) NOT NULL DEFAULT '1', `created` datetime NOT NULL, `modified` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `address` (`address`), KEY `domain_idx` (`domain`), CONSTRAINT `alias_domain_domain_domain` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`) ) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `config` -- DROP TABLE IF EXISTS `config`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `config` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '', `value` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='PostfixAdmin settings'; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `domain` -- DROP TABLE IF EXISTS `domain`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `domain` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `domain` varchar(255) NOT NULL, `description` varchar(255) DEFAULT NULL, `aliases` bigint(20) NOT NULL DEFAULT '0', `mailboxes` bigint(20) NOT NULL DEFAULT '0', `maxquota` bigint(20) NOT NULL DEFAULT '0', `quota` bigint(20) NOT NULL DEFAULT '0', `transport` varchar(255) NOT NULL DEFAULT 'virtual', `backupmx` tinyint(1) NOT NULL DEFAULT '0', `active` tinyint(1) DEFAULT '1', `created` datetime NOT NULL, `modified` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `domain` (`domain`), KEY `domain_idx` (`domain`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `domain_admin` -- DROP TABLE IF EXISTS `domain_admin`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `domain_admin` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `domain` varchar(255) NOT NULL, `created` datetime NOT NULL, PRIMARY KEY (`id`), KEY `username_idx` (`username`), KEY `domain_idx` (`domain`), CONSTRAINT `domain_admin_domain_domain_domain` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`), CONSTRAINT `domain_admin_username_admin_username` FOREIGN KEY (`username`) REFERENCES `admin` (`username`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `log` -- DROP TABLE IF EXISTS `log`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `log` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(255) DEFAULT NULL, `domain` varchar(255) DEFAULT NULL, `action` varchar(255) NOT NULL, `data` text NOT NULL, `timestamp` datetime NOT NULL, PRIMARY KEY (`id`), KEY `username_idx` (`username`), KEY `domain_idx` (`domain`), CONSTRAINT `log_domain_domain_domain` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`), CONSTRAINT `log_username_admin_username` FOREIGN KEY (`username`) REFERENCES `admin` (`username`) ) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `mailbox` -- DROP TABLE IF EXISTS `mailbox`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mailbox` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `name` varchar(255) DEFAULT NULL, `maildir` varchar(255) DEFAULT NULL, `quota` bigint(20) NOT NULL DEFAULT '0', `local_part` varchar(255) NOT NULL, `domain` varchar(255) NOT NULL, `access_restriction` varchar(255) NOT NULL DEFAULT 'BOTH', `active` tinyint(1) NOT NULL DEFAULT '1', `homedir` varchar(255) DEFAULT NULL, `uid` bigint(20) DEFAULT NULL, `gid` bigint(20) DEFAULT NULL, `created` datetime NOT NULL, `modified` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`), KEY `domain_idx` (`domain`), CONSTRAINT `mailbox_domain_domain_domain` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `migration_version` -- DROP TABLE IF EXISTS `migration_version`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `migration_version` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `version` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `token` -- DROP TABLE IF EXISTS `token`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `token` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `type` varchar(255) DEFAULT NULL, `token` varchar(64) DEFAULT NULL, `rid` varchar(64) DEFAULT NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`id`), KEY `username_idx` (`username`), CONSTRAINT `token_username_admin_username` FOREIGN KEY (`username`) REFERENCES `admin` (`username`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; |