电子邮件地址标记不适用于 Postfix 中的虚拟邮箱

电子邮件地址标记不适用于 Postfix 中的虚拟邮箱

我有自己的电子邮件服务器,我希望能够使用动态电子邮件地址标记。我recipient_delimiter = +-向配置中添加了该指令并重新启动了 postfix,但现在如果我发送电子邮件[email protected],电子邮件将被退回,并显示错误“未知用户”。如果我发送电子邮件,电子邮件将按预期[email protected]发送到帐户。webmaster

这是我的 postfix 配置:

## These are all default Postfix settings that we won't change
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
inet_interfaces = all
mailbox_command = /usr/lib/dovecot/deliver -c
    /etc/dovecot/conf.d/01-mail-stack-delivery.conf -m "${EXTENSION}"
mailbox_size_limit = 0
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +-
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/dovecot-auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_received_header = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
tls_random_source = dev:/dev/urandom

## Settings below this line are things we're modifying or adding

## Your mail server identity options
myhostname = mail.starbeamrainbowlabs.com
#mydestination = localhost, starbeamrainbowlabs.com,
#    localhost.starbeamrainbowalabs.com
# 89.107.190.141 = cross-code central
mynetworks = 127.0.0.0/8 192.168.0.0/24 [::ffff:127.0.0.0]/104 [::1]/128 89.107.190.141

## Customized smtpd paramters
smtpd_banner = $myhostname ESMTP
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks,
    check_helo_access hash:/etc/postfix/helo_access
    #reject_non_fqdn_helo_hostname,
    reject_invalid_helo_hostname,
    #reject_unknown_helo_hostname,
    #warn_if_reject, # warn us instead of actually blocking them
    permit
smtpd_sender_restrictions = permit_mynetworks,
    permit_sasl_authenticated,
    #reject_unknown_sender_domain,
    reject_sender_login_mismatch
smtpd_recipient_restrictions = permit_mynetworks,
    permit_sasl_authenticated,
    reject_unknown_client_hostname,
    reject_unknown_sender_domain,
    reject_unknown_recipient_domain,
    reject_unauth_pipelining,
    reject_unauth_destination, 
    reject_invalid_hostname,
    reject_non_fqdn_sender
smtpd_sender_login_maps = $virtual_mailbox_maps

## Dealing with rejection: use permanent 550 errors to stop retries
unknown_address_reject_code = 550
unknown_hostname_reject_code = 550
unknown_client_reject_code = 550

## customized TLS parameters
smtpd_tls_ask_ccert = yes
smtpd_tls_cert_file = /etc/ssl/private/chain/www-mail.starbeamrainbowlabs.com.pem
smtpd_tls_key_file = /etc/ssl/private/key/decrypted/www-mail.starbeamrainbowlabs.com.key
smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtpd_tls_ciphers = high
smtpd_tls_loglevel = 1
smtpd_tls_security_level = may
smtpd_tls_session_cache_timeout = 3600s


## Customized Dovecot and virtual user-specific settings
canonical_maps = hash:/etc/postfix/canonical
home_mailbox = Maildir/
message_size_limit = 104857600
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_mailbox_domains = hash:/etc/postfix/virtual-mailbox-domains
virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox-users
virtual_transport = dovecot

## This setting will generate an error if you restart Postfix before
## adding the appropriate service definition in master.cf, so make
## sure to get that taken care of!
dovecot_destination_recipient_limit = 1

## Customized milter settings
milter_default_action = accept
milter_connect_macros = j {daemon_name} v {if_name} _
non_smtpd_milters = $smtpd_milters
smtpd_milters = inet:127.0.0.1:11444 unix:/opendkim/opendkim.sock

## Other customized mail server settings
default_destination_concurrency_limit = 5
disable_vrfy_command = yes
relay_destination_concurrency_limit = 1
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may

/etc/postfix/master.cf,我有这个定义的 Dovecot:

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver
  -f ${sender} -d ${recipient}

我还对、、、、、、、以及其他一些定义进行了定义,ifmail但我bsmtp不完全确定它们的作用。scalemail-backendmailmanuucpscachemaildrop

有人知道这里发生了什么事以及我该如何解决吗?

我正在使用虚拟邮箱。

答案1

/etc/postfix/master.cf配置文件中,确保配置参数dovecot引用的服务定义设置virtual_transport为在调用期间抑制收件人地址的扩展部分/usr/lib/dovecot/deliver

例如,这可能不起作用,因为${recipient}将被[email protected]Postfix 的管道(8)服务:

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=dovecot:dovecot argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}

在这种情况下,应该将宏${recipient}替换为${user}@${domain},以便 Dovecot 传送代理[email protected]在其命令行中接收正确的地址:

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=dovecot:dovecot argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${domain}

参考:https://wiki1.dovecot.org/LDA/Postfix

答案2

参数中的多个字符recipient_delimiter似乎仅在 Postfix 2.11 或更高版本中受支持。请确保您正在运行较新的 Postfix 版本,或者仅使用一个分隔符。

postconf (5)手册页:

收件人分隔符(默认:空)

一组字符,用于将用户名与其扩展名(例如:user+foo)或 .forward 文件名与其扩展名(例如:.forward+foo)分隔开。基本上,软件会先尝试 user+foo 和 .forward+foo,然后再尝试 user 和 .forward。此实现会为每个电子邮件地址或 .forward 文件名识别一个分隔符和一个扩展名。

当recipient_delimiter集合包含多个字符(Postfix 2.11及更高版本)时,用户名或.forward文件名与其扩展名之间以与recipient_delimiter集合匹配的第一个字符分隔。

相关内容