Postfix 通过“Gmail”帐户发送电子邮件时出错

Postfix 通过“Gmail”帐户发送电子邮件时出错

我正在尝试使用 Fedora 23 通过我的个人“Gmail”帐户向其他“Gmail”帐户发送电子邮件。想法是通过 Postfix 发送电子邮件(用于服务器警报),但我没有公司/个人域名。我正在使用这个 Postfix 配置:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
compatibility_level = 2
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
meta_directory = /etc/postfix
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 185.12.5.172
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix/README_FILES
relayhost = [smtp.gmail.com]:587
sample_directory = /usr/share/doc/postfix/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
shlib_directory = /usr/lib64/postfix
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_use_tls = yes
unknown_local_recipient_reject_code = 550

我还创建了一个名为“sasl_password”的文件:

[smtp.gmail.com]:587    [email protected]:password

但是 Postfix 无法发送,因为“/var/log/maillog”中存在以下错误:

Nov 29 19:35:37 domain postfix/qmgr[4911]: 4A7B318739D4: from=<>, size=2577, nrcpt=1 (queue active)
Nov 29 19:35:37 domain postfix/smtp[6080]: cannot load Certification Authority data, CAfile="/etc/ssl/certs/ca-certificates.crt": disabling TLS support
Nov 29 19:35:37 domain postfix/smtp[6080]: warning: TLS library problem: error:02001002:system library:fopen:No such file or directory:bss_file.c:168:fopen('/etc/ssl/certs/ca-certificates.crt','r'):
Nov 29 19:35:37 domain postfix/smtp[6080]: warning: TLS library problem: error:2006D080:BIO routines:BIO_new_file:no such file:bss_file.c:171:
Nov 29 19:35:37 domain postfix/smtp[6080]: warning: TLS library problem: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib:by_file.c:258:
Nov 29 19:35:37 domain postfix/smtp[6080]: 4A7B318739D4: TLS is required, but our TLS engine is unavailable
Nov 29 19:35:38 domain postfix/smtp[6080]: 4A7B318739D4: TLS is required, but our TLS engine is unavailable
Nov 29 19:35:38 domain postfix/smtp[6080]: connect to smtp.gmail.com[2a00:1450:4010:c09::6d]:587: Network is unreachable
Nov 29 19:35:38 domain postfix/smtp[6080]: 4A7B318739D4: to=<linuxuser@domain>, relay=none, delay=1801, delays=1800/0.03/0.34/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[2a00:1450:4010:c09::6d]:587: Network is unreachable)
Nov 29 19:38:44 domain postfix/smtpd[6162]: connect from localhost[::1]
Nov 29 19:39:19 domain postfix/smtpd[6162]: NOQUEUE: reject: RCPT from localhost[::1]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<localhost>
Nov 29 19:39:31 domain postfix/smtpd[6162]: disconnect from localhost[::1] ehlo=1 mail=1 rcpt=0/1 quit=1 commands=3/4
Nov 29 19:39:33 domain postfix/smtpd[6162]: connect from localhost[::1]
Nov 29 19:40:04 domain postfix/smtpd[6162]: NOQUEUE: reject: RCPT from localhost[::1]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<root@localhost> to=<[email protected]> proto=ESMTP helo=<localhost>
Nov 29 19:41:50 domain postfix/smtpd[6162]: disconnect from localhost[::1] ehlo=1 mail=1 rcpt=0/1 quit=1 commands=3/4
Nov 29 19:45:10 domain postfix/anvil[6164]: statistics: max connection rate 2/60s for (smtp:::1) at Nov 29 19:39:33
Nov 29 19:45:10 domain postfix/anvil[6164]: statistics: max connection count 1 for (smtp:::1) at Nov 29 19:38:44
Nov 29 19:45:10 domain postfix/anvil[6164]: statistics: max cache size 1 at Nov 29 19:38:44

编辑1:

在编辑 SSL 证书并将我的 Google 帐户设置为安全性较低的版本后,我成功解决了该问题。我使用了本教程:

https://community.runabove.com/kb/en/instances/how-to-relay-postfix-mails-via-smtp.gmail.com-on-ubuntu-14.04.html

答案1

首先,您已强制使用 TLS,但您的 TLS 配置无效。请更正您的 TLS 配置或关闭 TLS。

接下来,您的服务器无法连接 gmail。这可能是因为它正在尝试使用 IPv6。如果您没有 IPv6 连接,请在操作系统或 postfix 中关闭 IPv6(在 main.cf 中inet_protocols从更改allipv4

第三,您的服务器似乎认为它对 gmail 具有权威性,但我不明白为什么。

相关内容