Ubuntu

Postfix - 無法接收來自外部域的電子郵件(Ubuntu 16.04)

  • February 26, 2019

早上好!

我有一個常見的問題,但是在閱讀了很多論壇和教程之後,我還沒有找到任何解決方案。很快:我想從外部域向我的伺服器發送一封電子郵件,但從未收到。

伺服器:

帶有 Ubuntu 16.04 的 VPS。

跟著教程:

https://www.digitalocean.com/communi...n-ubuntu-16-04 (在檢測到問題後還有很多其他問題,但那是主要問題)

我有/可以做的:

我沒有/不能做的事:

  • mail.log、syslog 中的任何錯誤日誌
  • 接收來自任何外部域(即 gmail.com)的電子郵件

我嘗試做的事情(但我做不到):

  • 從外部域(即 gmail.com)發送電子郵件並在我的 Maildir 中的 example.com 域中接收它

後綴 main.cf

# 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

myhostname = vps_name
mydomain = example.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 my_server_ip_address
mydestination = $myhostname, localhost, localhost.$mydomain, $mydomain

# 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_tls_cert_file=/etc/letsencrypt/live/example.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/example.com/privkey.pem

#smtpd_use_tls=yes
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

#smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
#smtpd_tls_protocols=!SSLv2

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

smtpd_sender_restrictions = permit_sasl_authenticated
smtpd_relay_restrictions = 
   permit_mynetworks 
   permit_sasl_authenticated 
   permit_inet_interfaces 
   reject_unauth_destination
smtpd_recipient_restrictions =
   permit_mynetworks 
   permit_sasl_authenticated
   permit_inet_interfaces
   reject_unauth_destination

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

relayhost = 

mailbox_command = 
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
myorigin = /etc/mailname

milter_protocol = 2
milter_default_action = accept

smtpd_milters = inet:localhost:12301
non_smtpd_milters = inet:localhost:12301
home_mailbox = Maildir/

virtual_alias_maps = hash:/etc/postfix/virtual

埠 25 監聽:

tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      32022/master
tcp6       0      0 :::25                   :::*                    LISTEN      32022/master

附加資訊

當我嘗試向我的域發送電子郵件時,我收到未送達消息:

Remote host said: 454 4.7.1 <admin@my_domain>: Relay access denied

如果我使用 mxtoolbox - ’test email server’,響應是:

Connecting to MY_VPS_IP

220 VPS_NAME ESMTP Postfix (Ubuntu) [1126 ms]
EHLO keeper-us-east-1b.mxtoolbox.com
250-VPS_NAME 
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN [705 ms]
MAIL FROM:<supertool@mxtoolbox.com>
250 2.1.0 Ok [687 ms]
RCPT TO:<test@mxtoolboxsmtpdiag.com>
554 5.7.1 <test@mxtoolboxsmtpdiag.com>: Relay access denied [690 ms]

LookupServer 8529ms

我花了很多時間試圖解決這個問題,但我失敗了。我將非常感謝任何建議我做錯了什麼以及如何解決問題。

我剛剛解決了這個問題。

問題在*/etc/aliases*內部。我在那裡:

postmaster: admin
admin: admin@example.com

當我進行電子郵件轉發時,第二行是之前後綴配置的殘餘。我忘了刪除它。現在我只剩下第一行了:

postmaster: admin

它工作正常。

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