Postfix / Dovecot 为不存在的用户配置电子邮件

Postfix / Dovecot 为不存在的用户配置电子邮件

我的 postfix / dovecot 安装已配置为接受 的邮件[email protected]。但是,由于我的 Apache 正在运行具有域名映射的多个虚拟域。我想创建一封[email protected]转发到 的电子邮件[email protected]。有没有标准的方法来处理这个问题?

编辑

好的,我按照 fkraiem 所说的做了,但发生了以下情况:

/usr/sbin/postconf: warning: /etc/postfix/main.cf, line 44: overriding earlier entry: virtual_alias_maps=hash:/etc/postfix/virtual_aliases

main.cf文件下方

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = A.com
alias_maps = hash:/etc/aliases, hash:/var/spool/postfix/plesk/aliases
alias_database = hash:/etc/aliases
mydestination = A.com, localdomain, localhost, localhost.localdomain, localhost
relayhost = 
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
virtual_alias_domains = B.net
virtual_alias_maps = hash:/etc/postfix/virtual_aliases
virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains
virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual
virtual_mailbox_maps = , hash:/var/spool/postfix/plesk/vmailbox
transport_maps = regexp:/etc/postfix/transport
smtpd_tls_security_level = may
smtp_tls_security_level = may
smtp_use_tls = no
smtpd_timeout = 3600s
smtpd_proxy_timeout = 3600s
disable_vrfy_command = yes
smtpd_sender_restrictions = check_sender_access hash:/var/spool/postfix/plesk/blacklists, permit_sasl_authenticated
smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated
smtp_send_xforward_command = yes
smtpd_authorized_xforward_hosts = 127.0.0.0/8 [::1]/128
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
virtual_mailbox_base = /var/qmail/mailnames
virtual_uid_maps = static:30
virtual_gid_maps = static:31
smtpd_milters = , inet:127.0.0.1:12768
sender_dependent_default_transport_maps = hash:/var/spool/postfix/plesk/sdd_transport_maps
virtual_transport = plesk_virtual
plesk_virtual_destination_recipient_limit = 1
mailman_destination_recipient_limit = 1
virtual_mailbox_limit = 0
smtp-1000_destination_rate_delay = 12s
smtp-1000_destination_concurrency_limit = 1
smtp-1000_destination_recipient_limit = 2
smtp-1000_initial_destination_concurrency = 1
myorigin = /etc/mailname
mynetworks = 127.0.0.0/8 127.0.0.1/32 IP/32 [::1]/128 [::2]/128
home_mailbox = Maildir/
smtpd_sasl_local_domain = 
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_tls_auth_only = no
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

发送电子邮件后我收到了这个错误:

5.1.0 - Unknown address error 550-'5.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual alias table'

答案1

您需要使用 Posftix 中的一种机制虚拟别名如果

  • 您的系统处理邮件domain.comIE,MX 记录指向它);并且
  • 您想要将发送到该@domain.com地址的所有邮件重定向到其他“真实”地址(无论它们是否也托管在您的系统上或其他地方,例如 Gmail)。

这很容易做到,主要有三个步骤。

  1. 将域添加domain.comvirtual_alias_domainsPostfix 配置中的指令中,mydestination如果存在,则将其从指令中删除。
  2. 创建虚拟别名文件,例如在/etc/postfix/virtual_aliases。在其中,输入如下行

    [email protected] [email protected]
    

    发送到文件中未明确映射的任何地址的邮件都将被拒绝,但您也可以添加一个像这样的万能地址

    @domain.com [email protected]
    

    然后sudo postmap /etc/postfix/virtual_aliases创建该文件的散列版本,Postfix 实际会使用它。

  3. 添加hash:/etc/postfix/virtual_aliasesvirtual_alias_maps您的 Postfix 配置中的指令。

重新加载 Postfix 后它应该会执行您想要的操作。

相关内容