Postfix:无法从其他网络发送邮件

Postfix:无法从其他网络发送邮件

我最近设置了一个 postfix(+dovecot)邮件服务器(在 VPS 上),当我在自己的家庭网络中(我将其放在 mynetworks 中)时,我既可以发送也可以接收邮件。

但是当我不在家时,我只能接收电子邮件,这不是我期望的行为,因为那时我可能需要发送电子邮件。以下是我的设置,如果您能帮助我:

# 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

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

#Mail filter

#milter_default_action = accept
#milter_protocol = 6
#smtpd_milters = unix:/var/run/clamav/clamav-milter
#non_smtpd_milters = unix:/var/run/clamav/clamav-milter

# TLS parameters
smtpd_tls_cert_file=/etc/letsencrypt/live/mail.myserver.dev/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/mail.myserver.dev/privkey.pem
smtpd_tls_security_level=encrypt
smtpd_use_tls = yes
smtpd_tls_auth_only = yes

smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_relay_restrictions = permit_sasl_authenticated, reject_unauth_destination
smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination

mydomain = myserver.dev
myhostname = $mydomain
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost.localdomain localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 123.456.789.159/32
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

virtual_mailbox_domains = myserver.dev
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_mailbox_base = /var/vmail

virtual_uid_maps = hash:/etc/postfix/virtual_uid
virtual_gid_maps = hash:/etc/postfix/virtual_gid

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

smtpd_client_connection_count_limit = 10
smtpd_client_connection_rate_limit = 30
smtpd_error_sleep_time = 1s
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 20

这里还有 master.cf

smtp      inet  n       -       y       -       -       smtpd
#smtp      inet  n       -       y       -       1       postscreen
#smtpd     pass  -       -       y       -       -       smtpd
#dnsblog   unix  -       -       y       -       0       dnsblog
#tlsproxy  unix  -       -       y       -       0       tlsproxy
submission inet n - n - - smtpd
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_sasl_security_options=noanonymous
  -o smtpd_sasl_local_domain=$myhostname
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o smtpd_sender_login_maps=hash:/etc/postfix/virtual
  -o smtpd_sender_restrictions=reject_sender_login_mismatch
  -o smtpd_recipient_restrictions=reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_sasl_authenticated,reject
#submission inet n       -       y       -       -       smtpd

我不知道我更改了什么设置,但现在我得到了不同的错误。我之前得到的第一个错误是:

May 26 11:57:36 vmi1240278 postfix/smtpd[1164363]: connect from unknown[XX.XXX.XX.XX]
May 26 11:57:37 vmi1240278 postfix/smtpd[1164363]: NOQUEUE: reject: RCPT from unknown[XX.XXX.XX.XX]: 554 5.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<smtpclient.apple>
May 26 11:57:37 vmi1240278 postfix/smtpd[1164363]: disconnect from unknown[XX.XXX.XX.XX] ehlo=2 starttls=1 mail=1 rcpt=0/1 quit=1 commands=5/6

现在我得到:

May 26 16:28:33 vmi1240278 postfix/smtpd[1177893]: connect from unknown[XX.XXX.XX.XX]
May 26 16:28:33 vmi1240278 postfix/smtpd[1177893]: NOQUEUE: reject: RCPT from unknown[XX.XXX.XX.XX]: 554 5.7.1 <unknown[XX.XXX.XX.XX]>: Client host rejected: Access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<smtpclient.apple>
May 26 16:28:33 vmi1240278 postfix/smtpd[1177893]: disconnect from unknown[XX.XXX.XX.XX] ehlo=2 starttls=1 mail=1 rcpt=0/1 quit=1 commands=5/6

可能有用的其他信息是,当我在邮件应用程序中使用连接检查器时,我获得 SMTP(翻译):已连接,无需进行身份验证,而对于 IMAP,我获得(翻译):已连接并已验证

对于 Gmail,我获得的结果与我的服务器的 IMAP 的 SMTP 和 IMAP 相同。

谢谢。

答案1

好吧,这可能听起来很蠢。

该问题与 Apple Mail 自动管理 SMTP 连接有关,我取消选中它并将身份验证选项从“无”改为“密码”。已修复。

相关内容