Ubuntu

Postfix 收不到郵件

  • March 27, 2015

我正在嘗試按照本指南在 ubuntu 12.04 中設置帶有 postfix 和 dovecot 的郵件伺服器。一切似乎都正常進行,當我嘗試這個時,echo test | mail email1@example.org一切都按預期進行。但是當我嘗試從我的 gmail 帳戶向伺服器發送郵件時,我收到了這個錯誤

Delivery to the following recipient failed permanently:

    email1@example.org

Technical details of permanent failure:
Google tried to deliver your message, but it was rejected by the server for the recipient domain example.org by aspmx.l.google.com. [2607:f8b0:4001:c05::1a].

The error that the other server returned was:
550-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 m1si13660174ige.61 - gsmtp

發送郵件失敗後,我嘗試用它測試郵件伺服器,由於我的 HTTPS 證書無效,我收到 1 個錯誤,由於我的自定義 SMTP 橫幅和缺少 SPF 記錄,我收到 7 個警告。關於如何更改我的 HTTPS 證書以及 gmail 是否存在問題的任何想法?

我還嘗試從這裡測試線上發送郵件,我得到了這個結果:

Resolving hostname...
Connecting...
SMTP -> FROM SERVER:
220 floatnet.org ESMTP Postfix (Ubuntu)
SMTP -> FROM SERVER: 
250-floatnet.org
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM: underworldseed@gmail.com
SMTP -> FROM SERVER:
530 5.7.0 Must issue a STARTTLS command first
SMTP -> ERROR: MAIL not accepted from server: 530 5.7.0 Must issue a STARTTLS command first

RCPT TO: email1@floatnet.org
SMTP -> FROM SERVER:
530 5.7.0 Must issue a STARTTLS command first
SMTP -> ERROR: RCPT not accepted from server: 530 5.7.0 Must issue a STARTTLS command first

Message sending failed.

這是我的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
smtpd_tls_cert_file=/etc/ssl/certs/dovecot.pem
smtpd_tls_key_file=/etc/ssl/private/dovecot.pem
smtpd_use_tls=yes
smtpd_tls_auth_only = yes

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions =
   permit_sasl_authenticated,
   permit_mynetworks,
   reject_unauth_destination

#smtpd_reject_unlisted_sender = no
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = floatnet.org
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
#mydestination = floatnet.org, vps2473.directvps.nl, localhost.directvps.nl, localhost
mydestination = localhost 
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf

relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
#smtpd_sasl_type = dovecot
#smtpd_sasl_path = private/auth-client
#smtpd_sasl_auth_enable = yes
#smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

實際上,儘管問題相同,但上面有兩個不同的錯誤消息:Failed to receive email

當您從 GMAIL 發送電子郵件時,出現了第一個錯誤。它因錯誤而失敗

Technical details of permanent failure:
Google tried to deliver your message, but it was rejected by the server for the recipient domain domain.org by aspmx.l.google.com. [2607:f8b0:4001:c05::1a].

Google拒絕你的郵件的原因是floatnet.org的MX記錄指向的是Gmail伺服器而不是postfix伺服器。

$ dig floatnet.org MX +short
20 ALT2.ASPMX.L.GOOGLE.COM.
30 ASPMX4.GOOGLEMAIL.COM.
30 ASPMX3.GOOGLEMAIL.COM.
30 ASPMX5.GOOGLEMAIL.COM.
30 ASPMX2.GOOGLEMAIL.COM.
20 ALT1.ASPMX.L.GOOGLE.COM.
10 ASPMX.L.GOOGLE.COM.

解決方案:修復您的 MX 記錄


第二個錯誤是在您測試 SMTP 伺服器時發現的。

 Must issue a STARTTLS command first

此錯誤可能與傳入 gmx-mail 的此問題後綴 TLS 配置重複。建議的解決方案是更改smtpd_tls_security_level為“可能”而不是“加密”。

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