如何让Postfix 能够向全世界发送消息?

如何让Postfix 能够向全世界发送消息?

我正在使用 PostgreSQL 配置基于 Postfix 的 SMTP 服务器。当我尝试向另一个域发送邮件时,我收到了收件人地址被拒绝:访问被拒绝错误。

这是我的配置:

# postconf -n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
local_recipient_maps = 
mailbox_size_limit = 0
mydestination = lan.example.com, localhost, localhost.localdomain, localhost
myhostname = example.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
readme_directory = no
recipient_delimiter = +
relayhost = lan.example.com
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, reject
virtual_alias_maps = pgsql:/etc/postfix/pgsql.d/virtual_alias.cf
virtual_gid_maps = static:108
virtual_mailbox_base = /var/spool/postfix/incoming
virtual_mailbox_domains = pgsql:/etc/postfix/pgsql.d/virtual_domain.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = pgsql:/etc/postfix/pgsql.d/virtual_mailbox.cf
virtual_transport = virtual
virtual_uid_maps = static:105

这里,示例.com是服务器的域名,并且lan.example.com是中继主机的域名。

完整的错误如下:

Oct 15 10:22:08 authentification postfix/smtpd[9930]: connect from unknown[10.1.250.173]
Oct 15 10:22:08 authentification postfix/smtpd[9930]: NOQUEUE: reject: RCPT from unknown[10.1.250.173]: 554 5.7.1 <[email protected]>: Recipient address rejected: Access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<localhost>
Oct 15 10:22:08 authentification postfix/smtpd[9930]: lost connection after RSET from unknown[10.1.250.173]
Oct 15 10:22:08 authentification postfix/smtpd[9930]: disconnect from unknown[10.1.250.173]

答案1

如果我没有误解你的问题,你想通过发送邮件lan.example.com。如果lan.example.com是同一个框,relayhost = lan.example.com则不应设置(因为这已经是中继主机)。

来自postfix 文档

By default, the Postfix SMTP server accepts:

  Mail from clients whose IP address matches $mynetworks, or
  Mail to remote destinations that match $relay_domains, except for addresses
   that contain sender-specified routing (user@elsewhere@domain), or
  Mail to local destinations that match $inet_interfaces or $proxy_interfaces,
    $mydestination, $virtual_alias_domains, or $virtual_mailbox_domains.

您应该指定网络10.1.250.0/24(或任何位掩码)作为 的一部分$mynetworks,或者具体将其放入 中smtpd_relay_restrictions

smtpd_relay_restrictions = $mynetworks, 10.1.250.0/24

相关内容