gpt4 book ai didi

mysql - 别名不起作用

转载 作者:行者123 更新时间:2023-11-29 02:59:12 26 4
gpt4 key购买 nike

我正在尝试使用 postfix 和 dovecot 设置邮件服务器,但是由于某些原因我无法使用别名。每次我向别名发送邮件时,我都会收到“用户未知”或“虚拟邮箱表中的用户未知”。我使用了 postmap -q alias@example.com mysql:/etc/postfix/mysql-virtual-alias-maps.cf 并返回 user@example.com正如预期的那样。我还在 mysql 中启用了查询日志记录,我可以看到查询已执行,但出于某种原因,它仍会检查用户 alias@example.com 是否存在,当然它不存在。

主.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-虚拟邮箱-domains.cf:

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

mysql-虚拟邮箱-maps.cf:

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

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=<CAGPeO-YPiiA5TerbFqZ5j5t-PYtGuR2wSaKXUN1=ewTdO-0=Zw@mail.gmail.com>
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 <CAGPeO-YPiiA5TerbFqZ5j5t-PYtGuR2wSaKXUN1=ewTdO-0=Zw@mail.gmail.com> 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=<CAGPeO-YPiiA5TerbFqZ5j5t-PYtGuR2wSaKXUN1=ewTdO-0=Zw@mail.gmail.com>,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=<xx@gmail.com>, 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=<xx@xx.in>, 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=<20141026153833.2012B580A53@xx.in>
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=<xx@gmail.com>, 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

最佳答案

找到解决方案,显然 receive_override_options = no_address_mappings 禁用虚拟别名,所以当我删除该行时,一切都开始按预期工作。

关于mysql - 别名不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26574540/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com