当我尝试从外部发送邮件到 postfix 时出现中继访问错误

当我尝试从外部发送邮件到 postfix 时出现中继访问错误

我运行 debian 7 系统,并运行 postfix 作为 smtp 服务器。我可以从 postfix 向外部发送邮件(即使它通过 google 发送到垃圾邮件文件夹),但是当我尝试从我的 google 帐户发送邮件到我的服务器时,我收到错误。

假设我的 IP 是 77.77.77.77,我的主机名 machine.host.org 和 dns:example.ru 我从 google 收到此错误:

Delivery to the following recipient failed permanently:

     [email protected]

Technical details of permanent failure: 
Google tried to deliver your message, but it was rejected by the server for the recipient domain example.ru by machine.host.org. [77.77.77.77].

The error that the other server returned was:
554 5.7.1 <[email protected]>: Relay access denied

我的 main.cf 是:

#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
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

# SSL/TLS certificates
smtpd_tls_cert_file=/etc/ssl/certs/mailcert.pem
smtpd_tls_key_file=/etc/ssl/private/mail.key
smtpd_use_tls = yes
smtpd_tls_auth_only = yes

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

# Hostname and domain name
myhostname = machine.host.org
mydomain = host.org
myorigin = /etc/mailname

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname localhost.$mydomain $mydomain
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 example.ru
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

# Anti-SPAM rules adapted from https://wiki.debian.org/Postfix
smtpd_recipient_restrictions = permit_sasl_authenticated,
        permit_mynetworks,
        check_policy_service unix:private/policy-spf,
        reject_invalid_hostname,
        reject_unknown_recipient_domain,
        reject_unauth_destination,
        reject_rbl_client sbl.spamhaus.org,
        permit

smtpd_helo_restrictions = reject_invalid_helo_hostname,
        reject_non_fqdn_helo_hostname,
        reject_unknown_helo_hostname

smtpd_client_restrictions = reject_rbl_client dnsbl.sorbs.net

# Mail will be stored in users ~/Maildir directories
home_mailbox = Maildir/
mailbox_command =

# From http://wiki2.dovecot.org/HowTo/PostfixAndDovecotSASL
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

# This changed the ups the policy time limit so the policy server won't time out while a message is still being processed.
policy-spf_time_limit = 3600s

# for OpenDKIM from https://tipstricks.itmatrix.eu/installing-opendkim-in-debian-squeeze/
milter_default_action = accept
milter_protocol = 6
smtpd_milters = inet:localhost:12345

我的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").
#
# 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_sasl_auth_enable=yes
  -o smtpd_client_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 milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       -       -       -       qmqpd
pickup    fifo  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  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
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 ${recipient}
#
# ====================================================================
#
# 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}
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=DRhu user=email:email argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}

policy-spf  unix  -       n       n       -       -       spawn
     user=nobody argv=/usr/bin/policyd-spf

/var/log/mail.log 的日志是:

Jan  6 16:20:41 vps127955 postfix/smtpd[16499]: connect from mail-we0-f170.google.com[1.1.1.1]
Jan  6 16:20:43 vps127955 policyd-spf[16501]: None; identity=helo; client-ip=1.1.1.1; helo=mail-we0-f170.google.com; [email protected]; [email protected]
Jan  6 16:20:43 vps127955 policyd-spf[16501]: Pass; identity=mailfrom; client-ip=1.1.1.1; helo=mail-we0-f170.google.com; [email protected]; [email protected]
Jan  6 16:20:43 vps127955 postfix/smtpd[16499]: NOQUEUE: reject: RCPT from mail-we0-f170.google.com[1.1.1.1]: 554 5.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mail-we0-f170.google.com>
Jan  6 16:20:43 vps127955 postfix/smtpd[16499]: disconnect from mail-we0-f170.google.com[1.1.1.1]

我怎么解决这个问题?

编辑1: 当我尝试从以下位置发送时[电子邮件受保护][电子邮件受保护]邮件未送达,我得到以下信息:

Jan  6 17:09:22 vps127955 postfix/smtpd[16675]: A00BF2C00CBE: client=localhost[::1]
Jan  6 17:09:27 vps127955 postfix/cleanup[16685]: A00BF2C00CBE: message-id=<[email protected]>
Jan  6 17:09:27 vps127955 postfix/qmgr[16476]: A00BF2C00CBE: from=<[email protected]>, size=354, nrcpt=1 (queue active)
Jan  6 17:09:27 vps127955 postfix/smtp[16686]: A00BF2C00CBE: to=<[email protected]>, relay=none, delay=13, delays=13/0.03/0.02/0, dsn=5.4.6, status=bounced (mail for example.ru loops back to myself)
Jan  6 17:09:27 vps127955 postfix/cleanup[16685]: E5DB12C00CC1: message-id=<[email protected]>
Jan  6 17:09:27 vps127955 postfix/qmgr[16476]: E5DB12C00CC1: from=<>, size=2549, nrcpt=1 (queue active)
Jan  6 17:09:27 vps127955 postfix/bounce[16687]: A00BF2C00CBE: sender non-delivery notification: E5DB12C00CC1
Jan  6 17:09:27 vps127955 postfix/qmgr[16476]: A00BF2C00CBE: removed
Jan  6 17:09:27 vps127955 postfix/smtp[16686]: E5DB12C00CC1: to=<[email protected]>, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=5.4.6, status=bounced (mail for example.ru loops back to myself)
Jan  6 17:09:27 vps127955 postfix/qmgr[16476]: E5DB12C00CC1: removed

但是当我尝试发送时[电子邮件受保护][电子邮件受保护]邮件已送达,我收到了

Jan  6 17:10:52 vps127955 postfix/smtpd[16675]: 1E2762C00CBE: client=localhost[::1]
Jan  6 17:10:57 vps127955 postfix/cleanup[16685]: 1E2762C00CBE: message-id=<[email protected]>
Jan  6 17:10:57 vps127955 opendkim[14116]: 1E2762C00CBE: no signing table match for '[email protected]'
Jan  6 17:10:57 vps127955 opendkim[14116]: 1E2762C00CBE: no signature data
Jan  6 17:10:57 vps127955 postfix/qmgr[16476]: 1E2762C00CBE: from=<[email protected]>, size=368, nrcpt=1 (queue active)
Jan  6 17:10:58 vps127955 postfix/local[16690]: 1E2762C00CBE: to=<[email protected]>, relay=local, delay=17, delays=16/0.14/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)
Jan  6 17:10:58 vps127955 postfix/qmgr[16476]: 1E2762C00CBE: removed

答案1

在 main.cf 中我改变了这一行

mydestination = $myhostname localhost.$mydomain $mydomain

进入行

mydestination = $myhostname localhost.$mydomain $mydomain example.ru

现在一切似乎都运行良好。但是,如果有人知道问题的实际原因是什么,请赐教!

相关内容