postfix/dovecot无法接收邮件的问题

postfix/dovecot无法接收邮件的问题

我的服务器无法接收邮件,但可以正常发送。

从我在日志中可以看出,它抱怨超时。我使用 PC 上的 telnet 检查外部连接,可以正常连接到端口 25。

它还谈到无法使用 mysql 执行某些操作,因此我稍微延长了超时限制并检查以确保我可以使用 myphpadmin 连接。从这方面来看,一切似乎都很顺利,所以我不知道为什么它会在那里抱怨。

在@roaima的帮助下,它现在会退回消息,但它声称“循环回到我自己”。如果你看一下postfix的my.cnf,你会发现我尝试了很多不同的mydestination方向,有的说它是环回的,有的说它不是中继主机。在研究了我遇到的错误后,它声称删除或添加我的 FQDN 可以修复它,但是在这两种情况下我都没有成功。

我可以很好地使用 Linux,但 postfix 却让我无法使用。

日志:/var/log/mail.log

Apr 22 15:26:37 webserver postfix/smtpd[36202]: connect from mail-wi0-f172.google.com[209.85.212.172]
Apr 22 15:26:38 webserver postfix/trivial-rewrite[36209]: warning: do not list domain zomgaming.net in BOTH mydestination and virtual_mailbox_domains
Apr 22 15:26:38 webserver postfix/smtpd[36202]: 20547C0E08: client=mail-wi0-f172.google.com[209.85.212.172]
Apr 22 15:26:38 webserver postfix/cleanup[36212]: 20547C0E08: message-id=<CAF++Fz1DrsMktsZ4k=FMRtjwfHP3mfPbVL2QoXxemqX_M69wkQ@mail.gmail.com>
Apr 22 15:26:38 webserver postfix/qmgr[36200]: 20547C0E08: from=<[email protected]>, size=1677, nrcpt=1 (queue active)
Apr 22 15:26:38 webserver amavis[50731]: (50731-11) NOTICE: reconnecting in response to: err=2006, HY000, DBD::mysql::st execute failed: MySQL server has gone away at (eval 136) line 170, <GEN31> line 770.
Apr 22 15:26:38 webserver postfix/smtpd[36202]: disconnect from mail-wi0-f172.google.com[209.85.212.172]
Apr 22 15:26:41 webserver postfix/smtpd[36216]: connect from localhost[127.0.0.1]
Apr 22 15:26:41 webserver postfix/smtpd[36216]: 7FBF9C0E3B: client=localhost[127.0.0.1]
Apr 22 15:26:41 webserver postfix/cleanup[36212]: 7FBF9C0E3B: message-id=<CAF++Fz1DrsMktsZ4k=FMRtjwfHP3mfPbVL2QoXxemqX_M69wkQ@mail.gmail.com>
Apr 22 15:26:41 webserver postfix/qmgr[36200]: 7FBF9C0E3B: from=<[email protected]>, size=2151, nrcpt=1 (queue active)
Apr 22 15:26:41 webserver postfix/smtpd[36216]: disconnect from localhost[127.0.0.1]
Apr 22 15:26:41 webserver amavis[50731]: (50731-11) Passed CLEAN {RelayedOpenRelay}, [209.85.212.172]:36328 [209.85.212.172] <[email protected]> -> <[email protected]>, Queue-ID: 20547C0E08, Message-ID: <CAF++Fz1DrsMktsZ4k=FMRtjwfH$
Apr 22 15:26:41 webserver postfix/smtp[36213]: 20547C0E08: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, delay=3.5, delays=0.25/0.01/0.01/3.2, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 $
Apr 22 15:26:41 webserver postfix/qmgr[36200]: 20547C0E08: removed
Apr 22 15:26:41 webserver postfix/smtp[36217]: 7FBF9C0E3B: to=<[email protected]>, relay=none, delay=0.28, delays=0.02/0.04/0.23/0, dsn=5.4.6, status=bounced (mail for mail.zomgaming.net loops back to myself)
Apr 22 15:26:41 webserver postfix/cleanup[36212]: C7091C16D3: message-id=<[email protected]>
Apr 22 15:26:41 webserver postfix/qmgr[36200]: C7091C16D3: from=<>, size=4101, nrcpt=1 (queue active)
Apr 22 15:26:41 webserver postfix/bounce[36218]: 7FBF9C0E3B: sender non-delivery notification: C7091C16D3
Apr 22 15:26:41 webserver postfix/qmgr[36200]: 7FBF9C0E3B: removed
Apr 22 15:26:42 webserver postfix/smtp[36217]: connect to gmail-smtp-in.l.google.com[2607:f8b0:400d:c06::1b]:25: Network is unreachable
Apr 22 15:26:43 webserver postfix/smtp[36217]: C7091C16D3: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[74.125.22.27]:25, delay=1.5, delays=0.01/0.01/0.62/0.85, dsn=2.0.0, status=sent (250 2.0.0 OK 1429716403 gn1si5368338$
Apr 22 15:26:43 webserver postfix/qmgr[36200]: C7091C16D3: removed
Apr 22 15:29:58 webserver postfix/anvil[36205]: statistics: max connection rate 1/60s for (smtp:209.85.212.172) at Apr 22 15:26:37
Apr 22 15:29:58 webserver postfix/anvil[36205]: statistics: max connection count 1 for (smtp:209.85.212.172) at Apr 22 15:26:37
Apr 22 15:29:58 webserver postfix/anvil[36205]: statistics: max message rate 1/60s for (smtp:209.85.212.172) at Apr 22 15:26:38
Apr 22 15:29:58 webserver postfix/anvil[36205]: statistics: max cache size 1 at Apr 22 15:26:37
Apr 22 15:30:02 webserver postfix/smtpd[36282]: connect from localhost[127.0.0.1]
Apr 22 15:30:02 webserver dovecot: imap-login: Disconnected (disconnected before auth was ready, waited 0 secs): user=<>, rip=127.0.0.1, lip=127.0.0.1, secured, session=<zbw01lEUXgB/AAAB>
Apr 22 15:30:02 webserver dovecot: pop3-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=127.0.0.1, lip=127.0.0.1, secured, session=<kQk11lEUFAB/AAAB>
Apr 22 15:30:02 webserver postfix/smtpd[36282]: lost connection after CONNECT from localhost[127.0.0.1]
Apr 22 15:30:02 webserver postfix/smtpd[36282]: disconnect from localhost[127.0.0.1]

输出:dig mx zomgaming.net

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> mx zomgaming.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44151
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;zomgaming.net.                 IN      MX

;; ANSWER SECTION:
zomgaming.net.          3599    IN      MX      1 zomgaming.net.

;; Query time: 66 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Mon Apr 13 10:34:04 UTC 2015
;; MSG SIZE  rcvd: 58

我在 godaddy 上的 mx 记录:

MX 1 zomgamgin.net.
MX 5 mail.zomgaming.net.

输出:/etc/hosts

127.0.0.1 localhost
#192.168.1.204  webserver.zomgaming.com webserver
192.168.1.204   zomgaming.net
#192.168.1.204  mail.zomgaming.net
73.172.71.230   webserver.zomgaming.com webserver
#73.172.71.230  zomgaming.net
127.0.0.1       mail.zomgaming.net

/etc/postfix/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 = /usr/share/doc/postfix

# TLS parameters
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.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 = webserver.zomgaming.com
mydomain = zomgaming.net
alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases
alias_database = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases
myorigin = /etc/mailname
#mydestination = webserver.zomgaming.com, localhost, localhost.localdomain
#mydestination = $myhostname localhost.$mydomain localhost $mydomain mail.$mydomain
#mydestination = webserver.zomgaming.com localhost.webserver.zomgaming.com localhost zomgaming.net mail.zomgaming.net
#mydestination = $mydomain, localhost.localdomain, localhost
#mydestination = $myhostname, localhost, localhost.localdomain
mydestination = webserver.zomgaming.com zomgaming.net
#relayhost =
mynetworks = 127.0.0.0/8 [::1]/128 192.168.1.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
html_directory = /usr/share/doc/postfix/html
#virtual_alias_domains =
virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman, proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, proxy:mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /var/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf
smtpd_tls_security_level = may
transport_maps = hash:/var/lib/mailman/data/transport-mailman, proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
relay_domains =
relay_recipient_maps = mysql:/etc/postfix/mysql-virtual_relayrecipientmaps.cf
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_can$
smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf
smtpd_client_restrictions = check_client_access mysql:/etc/postfix/mysql-virtual_client.cf
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
maildrop_destination_recipient_limit = 1
virtual_transport = dovecot
header_checks = regexp:/etc/postfix/header_checks
mime_header_checks = regexp:/etc/postfix/mime_header_checks
nested_header_checks = regexp:/etc/postfix/nested_header_checks
body_checks = regexp:/etc/postfix/body_checks
owner_request_special = no
smtp_tls_security_level = may
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_protocols = !SSLv2,!SSLv3
smtp_tls_protocols = !SSLv2,!SSLv3
dovecot_destination_recipient_limit = 1
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
content_filter = amavis:[127.0.0.1]:10024
receive_override_options = no_address_mappings
message_size_limit = 0
smtp_host_lookup = native

/etc/postfix/master.cf 的输出:

#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
#smtp      inet  n       -       -       -       1       postscreen
#smtpd     pass  -       -       -       -       -       smtpd
#dnsblog   unix  -       -       -       -       0       dnsblog
#tlsproxy  unix  -       -       -       -       0       tlsproxy
submission inet n       -       -       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       -       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       -       -       -       qmqpd
pickup    unix  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d vmail ${extension} ${recipient} ${user} ${nexthop} ${sender}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
#   lmtp    cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
#  mailbox_transport = lmtp:inet:localhost
#  virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
scalemail-backend unix  -       n       n       -       2       pipe
flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

dovecot   unix  -       n       n       -       -       pipe
  flags=DROhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}
amavis unix - - - - 2 smtp
        -o smtp_data_done_timeout=1200
        -o smtp_send_xforward_command=yes

127.0.0.1:10025 inet n - - - - smtpd
        -o content_filter=
        -o local_recipient_maps=
        -o relay_recipient_maps=
        -o smtpd_restriction_classes=
        -o smtpd_client_restrictions=
        -o smtpd_helo_restrictions=
        -o smtpd_sender_restrictions=
        -o smtpd_recipient_restrictions=permit_mynetworks,reject
        -o mynetworks=127.0.0.0/8
        -o strict_rfc821_envelopes=yes
        -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks

“主机名”的输出:

webserver.zomgaming.com

“主机名-f”的输出:

webserver.zomgaming.com

来自外部源的连接:

220 webserver.zomgaming.com ESMTP Postfix (Ubuntu)
>ehlo zomgaming.net
250-webserver.zomgaming.com
250-PIPELINING
250-SIZE
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
>mail from:<[email protected]>
501 5.5.4 Syntax: MAIL FROM:<address>
>mail from:<[email protected]>
250 2.1.0 Ok
>rcpt to:<[email protected]>
502 5.5.2 Error: command not recognized
>mail to:<[email protected]>
503 5.5.1 Error: nested MAIL command
>rcpt to:<[email protected]>
250 2.1.5 Ok
>data
354 End data with <CR><LF>.<CR><LF>
>this is a test
>.
250 2.0.0 Ok: queued as 648FFC128A
>quit

日志:

Apr 13 09:17:28 webserver postfix/qmgr[31156]: 648FFC128A: from=<[email protected]>, size=329, nrcpt=1 (queue active)
Apr 13 09:17:43 webserver postfix/smtpd[34632]: connect from localhost[127.0.0.1]
Apr 13 09:17:43 webserver postfix/smtpd[34632]: 950C9C39CC: client=localhost[127.0.0.1]
Apr 13 09:17:43 webserver postfix/cleanup[34617]: 950C9C39CC: message-id=<[email protected]>
Apr 13 09:17:43 webserver postfix/qmgr[31156]: 950C9C39CC: from=<[email protected]>, size=1013, nrcpt=1 (queue active)
Apr 13 09:17:43 webserver postfix/smtpd[34632]: disconnect from localhost[127.0.0.1]
Apr 13 09:17:43 webserver amavis[1254]: (01254-18) Passed BAD-HEADER-7 {RelayedOpenRelay,Quarantined}, [24.210.201.75]:12825 [24.210.201.75] <steve@exam$
Apr 13 09:17:43 webserver postfix/smtp[34629]: 648FFC128A: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, delay=165, delays=150/0.01/0.01/1$
Apr 13 09:17:43 webserver postfix/qmgr[31156]: 648FFC128A: removed
Apr 13 09:17:57 webserver postfix/smtpd[34531]: disconnect from cpe-24-210-201-75.neo.res.rr.com[24.210.201.75]
Apr 13 09:18:54 webserver postfix/smtp[34633]: connect to zomgaming.net[73.172.71.230]:25: Connection timed out
Apr 13 09:18:54 webserver postfix/smtp[34633]: 950C9C39CC: to=<[email protected]>, relay=none, delay=70, delays=0.02/0.04/70/0, dsn=4.4.1, status=deferred (connect to zomgaming.net[73.172.71.230]:25: Connection timed out)

好吧,我会尝试在内部与自己建立联系。

root@webserver:/home/admin# telnet zomgaming.net 25
Trying 127.0.0.1...
Connected to mail.zomgaming.net.
Escape character is '^]'.
220 webserver.zomgaming.com ESMTP Postfix (Ubuntu)

/etc/nsswitch.conf 的输出:

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

答案1

我们可以看到您的 Web 服务器也是您的邮件服务器,并且webserver.zomgaming.comzomgaming.net.

Postfix 知道它正在运行webserver.zomgaming.com,入站 SMTP 连接的 220 标语就证明了这一点。然而,Postfix 似乎并不知道它也是zomgaming.net(根据您的/etc/hosts文件),因此当它收到电子邮件时,[email protected]它会尝试连接到该“远程”主机以进行转发。大多数理智的邮件发送者拒绝与自己对话,因此即使它可以通过 127.0.0.1 与自己对话,尝试也注定会失败。

看一下mydestination配置选项main.cf

mydestination = webserver.zomgaming.com zomgaming.net

相关内容