我已经指定virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
,但仍然收到类似错误
警告:hash:/etc/postfix/virtual 不可用。打开数据库 /etc/postfix/virtual.db:没有此文件或目录
如果我创建虚拟和 virtual.db 文件,一切都可以正常工作,但我希望我的虚拟用户帐户存储在 DB 中,而不是文件中。
为什么 postfix 使用 virtual.db 文件而不是 db 表?
postconf -n
:
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
dovecot_destination_recipient_limit = 1
inet_interfaces = all
inet_protocols = ipv4
milter_default_action = accept
milter_protocol = 2
mydestination = localhost
non_smtpd_milters = unix:/var/run/opendkim/opendkim.sock
smtp_tls_note_starttls_offer = yes
smtpd_milters = unix:/var/run/opendkim/opendkim.sock
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = example.tst
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/dovecot/dovecot.pem
smtpd_tls_key_file = /etc/dovecot/private/dovecot.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = dovecot
实际上我在 master.cf 中有 /etc/postfix/virtual:
submission inet n - - - - smtpd
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_sasl_type=dovecot
-o smtpd_sasl_path=private/auth
-o smtpd_sasl_security_options=noanonymous
-o smtpd_sasl_local_domain=$myhostname
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
-o smtpd_sender_login_maps=hash:/etc/postfix/virtual
-o smtpd_sender_restrictions=reject_sender_login_mismatch
-o smtpd_recipient_restrictions=reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_sasl_authenticated,reject
答案1
问题出-o smtpd_sender_login_maps=hash:/etc/postfix/virtual
在 master.cf 中的那行。我忘了查看那里,因为这个配置在我的另一台服务器上运行了好几个月。
答案2
我通过修改以下行解决了这个问题etc/postfix/main.cf
:
virtual_alias_maps = hash:/etc/postfix/virtual
到
virtual_alias_maps = hash:/etc/aliases
(或者作为替代方案,只需创建etc/postfix/virtual
包含内容的文件):
your_linux_username: [email protected]
然后重新启动postfix: sudo systemctl restart postfix
然后邮件就发送了。