如何使Postfix能够发送消息给世界?

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

这是我的configuration:

# 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 <[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] 

如果我没有误解你的问题,你想通过lan.example.com发送邮件。 如果lan.example.com是同一个盒子, relayhost = 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. 

您应该指定networking10.1.250.0/24 (或任何位掩码)作为$mynetworks一部分,或者特别地将其放入smtpd_relay_restrictions

 smtpd_relay_restrictions = $mynetworks, 10.1.250.0/24