Postfix - 无法接收来自外部域的电子邮件(Ubuntu 16.04)

Postfix - 无法接收来自外部域的电子邮件(Ubuntu 16.04)

早上好!

我遇到了一个常见问题,但还没找到解决办法,尽管我看了很多论坛和教程。简而言之:我想从外部域向我的服务器发送一封电子邮件,但从未收到过。

服务器:

带有 Ubuntu 16.04 的 VPS。

按照教程:

https://www.digitalocean.com/communi...n-ubuntu-16-04 (在发现问题后还有很多其他问题,但这个问题是主要问题)

我有/可以做什么:

我没有/不能做的事情:

  • mail.log、syslog 中的任何错误日志
  • 从任何外部域接收电子邮件(例如 gmail.com)

我尝试去做(但做不到)的事情:

  • 从外部域(即 gmail.com)发送电子邮件,并在 example.com 域中的 Maildir 中接收它

Postfix 主配置文件

# 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 -‘测试电子邮件服务器’,则响应是:

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:<[email protected]>
250 2.1.0 Ok [687 ms]
RCPT TO:<[email protected]>
554 5.7.1 <[email protected]>: Relay access denied [690 ms]

LookupServer 8529ms

我花了很多时间试图解决这个问题,但失败了。如果大家能告诉我我做错了什么以及如何解决这个问题,我将不胜感激。

答案1

我刚刚解决了这个问题。

问题出在内部/etc/别名。我在那里:

postmaster: admin
admin: [email protected]

第二行是之前我设置邮件转发时留下的 postfix 配置。我忘了删除它了。现在只剩下第一行了:

postmaster: admin

而且它运行良好。

相关内容