2014-10-26 63 views
2

我想用postfix和dovecot设置邮件服务器,但是我无法使用别名工作。每次我发送一封邮件到一个别名,我会得到“用户未知”或“虚拟邮箱表中的用户未知”。我已使用postmap -q [email protected] mysql:/etc/postfix/mysql-virtual-alias-maps.cf,并按预期返回[email protected]。我也启用了查询日志记录在mysql中,我可以看到查询被执行,但由于某种原因,它仍然检查用户[email protected]是否存在,哪些当然不存在。别名不能正常工作

main.cf:

myhostname = xx 
smtpd_banner = \$myhostname ESMTP 
biff = no 
append_dot_mydomain = no 
readme_directory = /usr/share/doc/postfix 
smtpd_tls_cert_file = /etc/ssl/certs/xx.pem 
smtpd_tls_key_file = /etc/ssl/private/xx.key 
smtpd_use_tls = yes 
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache 
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache 
alias_maps = hash:/etc/aliases 
alias_database = hash:/etc/aliases 
myorigin = /etc/mailname 
mydestination = 
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 
mailbox_size_limit = 0 
recipient_delimiter = + 
inet_interfaces = all 
html_directory = /usr/share/doc/postfix/html 
inet_protocols = ipv4 
virtual_transport = dovecot 
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf 
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf 
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf 
virtual_minimum_uid = 100 
virtual_uid_maps = static:5000 
virtual_gid_maps = static:5000 
smtpd_helo_restrictions = reject_unknown_helo_hostname 
smtpd_sender_restrictions = reject_unknown_sender_domain 
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client zen.spamhaus.org, reject_rhsbl_reverse_client dbl.spamhaus.org, reject_rhsbl_helo dbl.spamhaus.org, reject_rhsbl_sender dbl.spamhaus.org 
smtpd_data_restrictions = reject_unauth_pipelining 
smtpd_sasl_type = dovecot 
smtpd_sasl_path = private/auth 
smtpd_sasl_auth_enable = yes 
smtpd_sasl_security_options = noanonymous 
dovecot_destination_recipient_limit = 1 
receive_override_options = no_address_mappings 
milter_connect_macros = j {daemon_name} v {if_name} _ 
milter_default_action = accept 
milter_protocol = 2 
smtpd_milters = unix:/spamass/spamass.sock, unix:/clamav/clamav-milter.ctl, inet:localhost:12301 
non_smtpd_milters = unix:/spamass/spamass.sock, unix:/clamav/clamav-milter.ctl, inet:localhost:12301 

mysql-virtual-alias-maps.cf:

user = mailcp 
password = xx 
hosts = 127.0.0.1 
dbname = mailcp 
query = SELECT CONCAT(user_alias.name, '@', domain.name) as destination FROM user_alias INNER JOIN domain ON user_alias.domainID = domain.id WHERE user_alias.primary = 1 AND user_alias.userID IN (SELECT user_alias.userID FROM user_alias INNER JOIN domain ON user_alias.domainID = domain.id WHERE CONCAT(user_alias.name, '@', domain.name)='%s'); 

mysql-virtual-mailbox-domains.cf:

user = mailcp 
password = xx 
hosts = 127.0.0.1 
dbname = mailcp 
query = SELECT 1 FROM domain WHERE name='%s'; 

的MySQL -virtual-mailbox-maps.cf:

​​

的dovecot-sql.conf.ext:

driver = mysql 
connect = host=127.0.0.1 dbname=databasename user=username password=changepwd 
default_pass_scheme = SHA512-CRYPT 
password_query = SELECT CONCAT(user_alias.name, '@', domain.name) as user, user.password as password, concat('*:bytes=', (CASE WHEN user.quota -1 THEN user.quota ELSE domain.quota END)*1000000) AS userdb_quota_rule FROM user INNER JOIN user_alias ON user.id = user_alias.userID AND user_alias.primary = 1 INNER JOIN domain ON user_alias.domainID = domain.id WHERE CONCAT(user_alias.name, '@', domain.name) ='%u' AND user.status = 1 
user_query = SELECT CONCAT('/var/mail/vmail/', domain.name, '/', user_alias.name) as home, 5000 AS uid, 5000 AS gid, concat('*:bytes=', (CASE WHEN user.quota != -1 THEN user.quota ELSE domain.quota END)*1000000) AS userdb_quota_rule FROM user INNER JOIN user_alias ON user.id = user_alias.userID AND user_alias.primary = 1 INNER JOIN domain ON user_alias.domainID = domain.id WHERE CONCAT(user_alias.name, '@', domain.name) ='%u' AND user.status = 1 

mail.info(对于一个邮件)

Oct 26 16:38:27 xx postfix/smtpd[538]: connect from mail-wg0-f51.google.com[74.125.82.51] 
Oct 26 16:38:28 xx postfix/smtpd[538]: 1FD73580A0F: client=mail-wg0-f51.google.com[74.125.82.51] 
Oct 26 16:38:28 xx postfix/cleanup[547]: 1FD73580A0F: message-id=<[email protected]om> 
Oct 26 16:38:28 xx spamd[29841]: spamd: connection from localhost.localdomain [127.0.0.1] at port 58956 
Oct 26 16:38:28 xx spamd[29841]: spamd: processing message <[email protected]om> for xx:1001 
Oct 26 16:38:33 xx spamd[29841]: spamd: clean message (-0.7/5.0) for xx:1001 in 4.9 seconds, 1789 bytes. 
Oct 26 16:38:33 xx spamd[29841]: spamd: result: . 0 - FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_DKIM_INVALID scantime=4.9,size=1789,user=xx,uid=1001,required_score=5.0,rhost=localhost.localdomain,raddr=127.0.0.1,rport=58956,mid=<[email protected]om>,autolearn=ham 
Oct 26 16:38:33 xx opendkim[25686]: 1FD73580A0F: mail-wg0-f51.google.com [74.125.82.51] not internal 
Oct 26 16:38:33 xx opendkim[25686]: 1FD73580A0F: not authenticated 
Oct 26 16:38:33 xx opendkim[25686]: 1FD73580A0F: DKIM verification successful 
Oct 26 16:38:33 xx spamd[29840]: prefork: child states: II 
Oct 26 16:38:33 xx postfix/qmgr[477]: 1FD73580A0F: from=<[email protected]>, size=1749, nrcpt=1 (queue active) 
Oct 26 16:38:33 xx dovecot: auth-worker(552): mysql(127.0.0.1): Connected to database mailcp 
Oct 26 16:38:33 xx postfix/pipe[550]: 1FD73580A0F: to=<[email protected]>, relay=dovecot, delay=5.1, delays=5/0/0/0.03, dsn=5.1.1, status=bounced (user unknown) 
Oct 26 16:38:33 xx postfix/cleanup[547]: 2012B580A53: message-id=<[email protected]> 
Oct 26 16:38:33 xx postfix/bounce[554]: 1FD73580A0F: sender non-delivery notification: 2012B580A53 
Oct 26 16:38:33 xx postfix/qmgr[477]: 2012B580A53: from=<>, size=3908, nrcpt=1 (queue active) 
Oct 26 16:38:33 xx postfix/qmgr[477]: 1FD73580A0F: removed 
Oct 26 16:38:33 xx postfix/smtpd[538]: disconnect from mail-wg0-f51.google.com[74.125.82.51] 
Oct 26 16:38:33 xx postfix/smtp[556]: 2012B580A53: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[74.125.195.27]:25, delay=0.2, delays=0/0/0.09/0.1, dsn=2.0.0, status=sent (250 2.0.0 OK 1414337913 dk6si7742912wib.44 - gsmtp) 
Oct 26 16:38:33 xx postfix/qmgr[477]: 2012B580A53: removed 
+0

您可以粘贴由postfix生成的完整日志行以帮助您更好地进行操作。 – clement 2014-10-26 15:26:35

+0

日志条目已添加。 – BlackVoid 2014-10-26 15:41:17

回答

1

实测值的溶液,显然receive_override_options = no_address_mappings禁用虚拟别名,所以当我除去一切线开始按预期工作。