Postfix

如何使 Postfix 能夠向世界發送消息?

  • October 15, 2012

我正在使用 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

這裡example.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 <david.jose.delassus@gmail.com>: Recipient address rejected: Access denied; from=<noreply@example.com> to=<david.jose.delassus@gmail.com> 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]

如果我沒有誤解你的問題,你想通過lan.example.com. 如果lan.example.com是同一個框,relayhost = lan.example.com則不應設置(因為這已經是中繼主機)。

後綴文件

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

引用自:https://serverfault.com/questions/438426