如何将本地域用户设置为虚拟用户?我已经设置了虚拟域和用户,但发送电子邮件时它一直提示“未找到用户”。为了测试问题所在,我向虚拟域中不存在的用户发送了一封电子邮件,错误是“未找到虚拟邮箱”。我需要找到一种方法来将本地域模拟为虚拟域,以便它从数据库中读取用户?以下是 Postfix 配置:
## SASL
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
## SSL/TLS
#smtpd_tls_security_level = may
smtpd_tls_received_header = yes
smtpd_tls_auth_only = yes
smtpd_tls_cert_file=/etc/postfix/ssl/smtpd.cert
smtpd_tls_key_file=/etc/postfix/ssl/smtpd.key
smtpd_tls_ask_ccert = yes
smtpd_use_tls=yes
smtp_use_tls=yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_session_cache_timeout = 3600s
smtp_tls_protocols = SSLv3, TLSv1
tls_random_source = dev:/dev/urandom
## Restrictions
message_size_limit = 30720000
smtpd_helo_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_hostname, reject_invalid_hostname
smtpd_sender_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,
reject_unauth_destination
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_sender_restrictions = reject_unknown_sender_domain
smtpd_banner = $myhostname ESMTP $mail_name
## Network
mydestination = $mydomain, $myhostname, localhost
mynetworks = 127.0.0.0/8
inet_interfaces = all
## Virtual
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_domain_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf
## DKIM
milter_protocol = 2
milter_default_action = accept
smtpd_milters = inet:localhost:12301
non_smtpd_milters = inet:localhost:12301
和鸽舍配置:
#10-auth.conf
disable_plaintext_auth = yes
#auth_cache_size = 0
#auth_cache_ttl = 1 hour
#auth_cache_negative_ttl = 1 hour
#auth_debug_passwords = yes
#auth_realms =
#auth_default_realm =
auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@
#auth_username_translation =
#auth_username_format = %Lu
#auth_master_user_separator =
#auth_anonymous_username = anonymous
#auth_worker_max_count = 30
#auth_gssapi_hostname =
#auth_krb5_keytab =
#auth_use_winbind = no
#auth_winbind_helper_path = /usr/bin/ntlm_auth
#auth_failure_delay = 2 secs
#auth_ssl_require_client_cert = no
#auth_ssl_username_from_cert = no
auth_mechanisms = plain login
passdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext
}
userdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext
# args = uid=5000 gid=5000 home=/var/vmail/%d/%n allow_all_users=yes
}
#dovecot-sql.conf.ext
default_pass_scheme = SHA512-CRYPT
password_query = SELECT username AS user, password, \
homedir AS userdb_home, uid AS userdb_uid, gid AS userdb_gid \
from mailbox where username = '%u' and active=1
user_query = \
SELECT homedir, uid, gid \
FROM mailbox WHERE username = '%u' and active=1
消息确实被发送到虚拟域,但没有被发送到本地域,并且我收到以下警告:
postfix/trivial-rewrite[18548]: warning: do not list domain example.tld in BOTH mydestination and virtual_mailbox_domain
我希望所有用户都通过 mysql 进行设置,并且在 /var/vmail/%d/%u 下创建目录,目前它仅适用于虚拟域。
编辑:添加详细信息
答案1
我找到了自己问题的答案。问题是域名在 mydestination 中,这使得通过该域名发送的电子邮件要经过local_recipients_maps
。删除域名解决了这个问题。我不知道这是最佳实践还是local_recipients_maps
使用 mysql 的覆盖。如果有人对此有答案,请在评论中写下来。