如何阻止 Postfix 接受邮件到 root@hostname.localdomain

Jef*_*eff 5 postfix

如何阻止 Postfix 接受来自外部世界的本地用户@my-FQDN 的邮件?

$ hostname -f
hostname.example.com
Run Code Online (Sandbox Code Playgroud)

Postfix 正在接受发送到 my-FQDN 的任何本地用户的邮件。因此,我们将使用root@hostname.example.com我想停止接收来自外部世界的邮件的本地用户作为示例。

我有一个非常基本的 Postfix/Dovecot/SASL/LDA 设置,但让我分享一些细节。

  • 在 :25 接收虚拟本地域/用户的邮件
  • 虚拟用户通过 Dovecot SASL 在 :587 上发送邮件

我试过在/etc/aliasesPostfix 和 Postfix 中反转用户virtual_alias_maps.cf,但没有运气。我在更新它们后运行了newaliasespostmap

#/etc/aliases:
#root: user@example.com

#/etc/postfix/virtual_alias_maps.cf:
root user@example.com
Run Code Online (Sandbox Code Playgroud)

我想我还剩下四个*(更新的)选择......

  1. 在 postfix/main.cf 中,弄乱mydestination. 我很确定我需要在这里保留我的 FQDN,所以我认为删除它不是一个好的选择。编辑:是的,虽然从mydestination 中删除您的 FQDN会禁止外部世界向本地用户发送邮件,但这不是禁用它的正确方法,因为这会导致其他事情。
  2. 在 postfix/main.cf 中,是否有smtpd_recipient_restrictions禁用此功能的设置?我在文档中找不到一个。
  3. 希望有人读到这个谁知道正确的方法。

这是我的 Postfix main.cf的相关部分:

myhostname = hostname.example.com
mydomain = example.com
mydestination = $myhostname, localhost.$mydomain, localhost

smtpd_recipient_restrictions =
    reject_unknown_recipient_domain,
    reject_non_fqdn_recipient,
    reject_unauth_destination,
    permit_mynetworks,
    permit
Run Code Online (Sandbox Code Playgroud)

这是我的 Postfix master.cf的相关部分:

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_recipient_restrictions=
     reject_unknown_recipient_domain,
     reject_non_fqdn_recipient,
     permit_sasl_authenticated,
     reject
Run Code Online (Sandbox Code Playgroud)

PS这是我从以下位置获取了很多设置的方法:VirtualUserFlatFilesPostfix

ALe*_*hha 4

只需从 mydestination 中删除 $myhostname 并重新启动 postfix