这是我的 main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = localhost
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
default_transport = smtp
relay_transport = smtp
inet_protocols = all
myorigin = /etc/mailname
在我本地机器上和我使用的某些服务器上也是一样。此外,在应用时,netstat -nltp |grep master
我在服务器和本地都得到了相同的输出:
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 29325/master
tcp6 0 0 :::25 :::* LISTEN 29325/master
并使用以下方式从本地机器发送电子邮件:
echo 'test' | mail -s 'test' [email protected]
它 100% 正常工作并且我可以直接收到电子邮件;但是当我尝试在服务器上执行同样的事情时它不工作。
任何帮助都会很有帮助。谢谢
更新
#忘记从 /var/log/mail.log 添加服务器上的错误
connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c06::1a]:25: Network is unreachable
答案1
原来是服务器提供商阻止了所有 smtp 通信。因此他们提供了一个网关解决方案来解决这个问题。如果您遇到同样的情况,请联系您的服务器公司。