我一直在遵循各种指南,了解如何通过 exim 和我的 gmail 帐户从 ubuntu 服务器发送电子邮件。我想我已经在这方面尝试过很多次了,但不知何故我搞砸了。有人能看出哪里不对劲吗?
我不想在此论坛帖子中包含任何真实的电子邮件地址或域名,因此,每当它们出现在配置文件等中时,我都会按如下方式替换它们。我将使用愚蠢的名称而不是描述性名称,这样它们就不会与系统变量等混淆。
domain name for the server: bigspanners.com
username i'm logged into the server as: jimmy
hostname on the server: spanners
"long" hostname (result of `hostname -f`): spanners.bigspanners.com
the gmail address i want to send from: [email protected]
gmail password: abcdefgh
我的 exim4 配置(/etc/exim4/update-exim4.conf.conf
)如下所示:
#/etc/exim4/update-exim4.conf.conf
dc_eximconfig_configtype='smarthost'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost='bigspanners.com'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.gmail.com::587'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname='false'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
我有这个/etc/exim4/passwd.client
文件:
# password file used when the local exim is authenticating to a remote
# host as a client.
#
# see exim4_passwd_client(5) for more documentation
#
# Example:
### target.mail.server.example:login:password
gmail-smtp.l.google.com:[email protected]:abcdefgh
*.google.com:[email protected]:abcdefgh
smtp.gmail.com:[email protected]:abcdefgh
我有这个/etc/email-addresses
# This is /etc/email-addresses. It is part of the exim package
#
# This file contains email addresses to use for outgoing mail. Any local
# part not in here will be qualified by the system domain as normal.
#
# It should contain lines of the form:
#
#user: [email protected]
#otheruser: [email protected]
jimmy: [email protected]
jimmy@localhost: [email protected]
jimmy@hostname1: [email protected]
[email protected]: [email protected]
我正在尝试发送如下电子邮件:
echo "This is a test." | mail -s Testing [email protected]
我在我的/var/log/exim4/mainlog
文件中看到了这一点:
2014-04-16 13:57:50 1WaQLW-0002dC-9k <= [email protected] U=jimmy P=local S=445
2014-04-16 13:57:51 1WaQLW-0002dC-9k plain authenticator failed H=gmail-smtp-msa.l.google.com [173.194.64.108] 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsuj
534-5.7.14 B3VqEmiHZ1icpT_O185MznNwotW78A3DdsElZPGAkfsIWQdd5de1lNbXoR-xdqK5Ko_Rs5
534-5.7.14 8zXBl2vzfUDPSF08dULZVaF8z999DpQNslK02DfEG0YcTUOxLqoosEzuxHA1vG-_bIxi9L
534-5.7.14 hMsYKcMkWJ7g4wf4xG-LK6c1sKQhFx-u1zcsUyLykkzI1qtGXYF5NC-ZpdnALCdQZ3hzUh
534-5.7.14 aAoXTLg> Please log in via your web browser and then try again.
534-5.7.14 Learn more at https://support.google.com/mail/bin/answer.py?answer=787
534 5.7.14 54 tz6sm39939105obc.10 - gsmtp
2014-04-16 13:57:51 1WaQLW-0002dC-9k login authenticator failed H=gmail-smtp-msa.l.google.com [173.194.64.108] 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbvT4
534-5.7.14 CHLiBFGLWWXIojohtPd9cIM1vLOt1MMyjSUzcFdXOarqE18FzPPxmU9e32_CveJOax5nnB
534-5.7.14 _7-adgi6NtHxbChOOxjRpd8xZCLgNnSjiHFWcbYeLLCZbv-7l6zylE7poh8nFe7SgTEINk
534-5.7.14 Lx1XvFQH1RuA1HJCwsC6nC-jG_4HQF7TY8ma9PBJWv4gz9fNna7wZFX4eeWtFTgpg7dKrX
534-5.7.14 wGYmwwQ> Please log in via your web browser and then try again.
534-5.7.14 Learn more at https://support.google.com/mail/bin/answer.py?answer=787
534 5.7.14 54 tz6sm39939105obc.10 - gsmtp
2014-04-16 13:57:51 1WaQLW-0002dC-9k ** [email protected] R=smarthost T=remote_smtp_smarthost: SMTP error from remote mail server after MAIL FROM:<[email protected]> SIZE=1480: host gmail-smtp-msa.l.google.com [173.194.64.108]: 530-5.5.1 Authentication Required. Learn more at\n530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 tz6sm39939105obc.10 - gsmtp
2014-04-16 13:57:51 1WaQLX-0002dT-QM <= <> R=1WaQLW-0002dC-9k U=Debian-exim P=local S=1595
2014-04-16 13:57:51 1WaQLW-0002dC-9k Completed
2014-04-16 13:57:52 1WaQLX-0002dT-QM plain authenticator failed H=gmail-smtp-msa.l.google.com [173.194.64.108] 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbt1l
534-5.7.14 LT1ysO4nisev9cFYPlQZ0Lk_Y0VvwVmgOWTJOEbZzYo5JOP9vMCoh-wwEXhq-8pUkhKejG
534-5.7.14 KRUNECT5VykeH6TSNQ8MR8ZoXe36ZZhpiZXCr0Smbjq512Lq_D5tozz9A9o1_JQePR05w6
534-5.7.14 RjyOK481V2Th6RhKwKqlBsvxfWKbs7twgxyklxBTRihFUEkJpFXDzvWNfUNJhkQq0MJnHv
534-5.7.14 53T4KeQ> Please log in via your web browser and then try again.
534-5.7.14 Learn more at https://support.google.com/mail/bin/answer.py?answer=787
534 5.7.14 54 sm4sm23756569obc.3 - gsmtp
2014-04-16 13:57:53 1WaQLX-0002dT-QM login authenticator failed H=gmail-smtp-msa.l.google.com [173.194.64.108] 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbt09
534-5.7.14 0DeijxwxzvClKfwY3oc1IhhkdSt_3suNtEsij4ibdikNtCMCiogd6mOma3obSAu2J5PlVh
534-5.7.14 QnZAN8CalbSYOX7mzuQyVqErqsY9uv5yuObmXk8771WBGrOzIxaOTnzChpd_ZVVeSGfmnh
534-5.7.14 qU5KHUrFo-qvHuYuqNZ1IsnbCkDKpov095uSs9wsbqA2WDEIKMI97EScrbjSNTJ35gdzOx
534-5.7.14 D_2ZhLA> Please log in via your web browser and then try again.
534-5.7.14 Learn more at https://support.google.com/mail/bin/answer.py?answer=787
534 5.7.14 54 sm4sm23756569obc.3 - gsmtp
2014-04-16 13:57:53 1WaQLX-0002dT-QM ** [email protected] R=smarthost T=remote_smtp_smarthost: SMTP error from remote mail server after MAIL FROM:<> SIZE=2655: host gmail-smtp-msa.l.google.com [173.194.64.108]: 530-5.5.1 Authentication Required. Learn more at\n530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 sm4sm23756569obc.3 - gsmtp
2014-04-16 13:57:53 1WaQLX-0002dT-QM Frozen (delivery error message)
2014-04-16 14:00:13 1WaQNg-0002eG-NX <= [email protected] U=jimmy P=local S=2381
2014-04-16 14:00:13 1WaQNg-0002eG-NX == jimmy@localhost R=local_user T=mail_spool defer (13): Permission denied: creating lock file hitching post /var/mail/jimmy.lock.spanners.bigspanners.com.534e8ced.000027cc (euid=1000 egid=8)
抱歉这篇文章太长了,但我试图提供我认为可能相关的任何信息。有人能看出哪里错了吗?
编辑:我刚想到了其他可能相关的事情:我已将 iptables 设置为允许所有传出请求,但阻止所有传入请求(白名单上的请求除外)。我不知道 gmail 身份验证如何工作:可能是身份验证过程的一部分被阻止,因为它来自非白名单端口,这就是它失败的原因?这是我的 iptables 规则:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere 127.0.0.0/8 reject-with icmp-port-unreachable
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:www
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:24367
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT tcp -- anywhere anywhere tcp dpt:2812
LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix `iptables denied: '
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:2812
编辑 2:自从发布此信息以来,我收到了来自 Gmail 的通知,说“有人试图访问您的电子邮件帐户,是你吗?”(或类似的话),列出了我的服务器的 IP 地址。我点击了“是的,是我”框,然后再次尝试,但仍然不起作用。
答案1
几个小时前就出现了同样的问题,但这不是配置问题,而是谷歌阻止了帐户访问,因为您尝试从其他 IP 登录,然后正常登录。
打开http://www.google.com/accounts/DisplayUnlockCaptcha然后尝试使用以下方法发送电子邮件:echo 'My Test Text' | mail -s Testmail[电子邮件保护]
/etc/exim4/passwd.client:
# password file used when the local exim is authenticating to a remote
# host as a client.
#
# see exim4_passwd_client(5) for more documentation
#
# Example:
### target.mail.server.example:login:password
gmail-smtp.l.google.com:[email protected]:yourpassword
*.google.com:[email protected]:yourpassword
smtp.gmail.com:[email protected]:yourpassword
/etc/exim4/更新-exim4.conf.conf:
# /etc/exim4/update-exim4.conf.conf
# (...)
# This is a Debian specific file
dc_eximconfig_configtype='satellite'
dc_other_hostnames='ServerName'
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost='yourdomain_which_points_to_server.com'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.gmail.com::587'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
答案2
如果 tls 协商未正确完成,Gmail 身份验证将失败。检查您在与 gmail 通信时确实使用了 starttls。您可以使用 -d-all+tls+transport 运行 exim。
这应该会提供更多信息