我有一个非常奇怪的问题。当发生内部服务器错误时,Django 1.6 会尝试向管理员发送电子邮件,并且显然它同意邮件服务器使用 TLS,但随后无法使用它。这是嗅探到的流量:
T 2a00:1450:400c:c0c::6d:587 -> 2001:648:2ffc:1014:a800:ff:fe6b:e499:49271 [AP]
220 smtp.gmail.com ESMTP lh1sm2677557wjb.20 - gsmtp..
##
T 2001:648:2ffc:1014:a800:ff:fe6b:e499:49271 -> 2a00:1450:400c:c0c::6d:587 [AP]
ehlo peneios.cressendo.org..
##
T 2a00:1450:400c:c0c::6d:587 -> 2001:648:2ffc:1014:a800:ff:fe6b:e499:49271 [AP]
250-smtp.gmail.com at your service, [2001:648:2ffc:1014:a800:ff:fe6b:e499].
.250-SIZE 35882577..250-8BITMIME..250-STARTTLS..250-ENHANCEDSTATUSCODES..25
0-PIPELINING..250-CHUNKING..250 SMTPUTF8..
#
T 2001:648:2ffc:1014:a800:ff:fe6b:e499:49271 -> 2a00:1450:400c:c0c::6d:587 [AP]
STARTTLS..
#
T 2a00:1450:400c:c0c::6d:587 -> 2001:648:2ffc:1014:a800:ff:fe6b:e499:49271 [AP]
220 2.0.0 Ready to start TLS..
#
T 2001:648:2ffc:1014:a800:ff:fe6b:e499:49271 -> 2a00:1450:400c:c0c::6d:587 [AP]
mail FROM:<noreply@hydroscope.gr> size=6578..
#
T 2a00:1450:400c:c0c::6d:587 -> 2001:648:2ffc:1014:a800:ff:fe6b:e499:49271 [AP]
......F
如您所见,虽然邮件服务器同意启动 TLS,但 Django 随后发送了一个未加密的mail FROM:
指令。
但是,如果我连接到 Django./manage.py shell
并运行它:
from django.core.mail import mail_admins
mail_admins('hello', 'hello world')
电子邮件发送正确:
T 2a00:1450:400c:c09::6c:587 -> 2001:648:2ffc:1014:a800:ff:fe6b:e499:53565 [AP]
220 smtp.gmail.com ESMTP i2sm2684051wjx.42 - gsmtp..
##
T 2001:648:2ffc:1014:a800:ff:fe6b:e499:53565 -> 2a00:1450:400c:c09::6c:587 [AP]
ehlo peneios.cressendo.org..
##
T 2a00:1450:400c:c09::6c:587 -> 2001:648:2ffc:1014:a800:ff:fe6b:e499:53565 [AP]
250-smtp.gmail.com at your service, [2001:648:2ffc:1014:a800:ff:fe6b:e499].
.250-SIZE 35882577..250-8BITMIME..250-STARTTLS..250-ENHANCEDSTATUSCODES..25
0-PIPELINING..250-CHUNKING..250 SMTPUTF8..
#
T 2001:648:2ffc:1014:a800:ff:fe6b:e499:53565 -> 2a00:1450:400c:c09::6c:587 [AP]
STARTTLS..
#
T 2a00:1450:400c:c09::6c:587 -> 2001:648:2ffc:1014:a800:ff:fe6b:e499:53565 [AP]
220 2.0.0 Ready to start TLS..
#
T 2001:648:2ffc:1014:a800:ff:fe6b:e499:53565 -> 2a00:1450:400c:c09::6c:587 [AP]
...........z/x....%....y.F.F..i..8.._w...S...z.0.,.2.../.+.1.-.........(.$.
....*.&.....k.j.9.8.'.#.....).%.....g.@.3.2.............E.D.........=.5.<./
[practically nothing readable from this point on]