2016-11-10 42 views
0

我无法从python发送电子邮件。可能存在安全问题。有人可以给我一个提示吗? 这是代码:Python邮件超时错误

import smtplib 

server = smtplib.SMTP('smtp.gmail.com', 587) 

server.starttls() 

#Next, log in to the server 
server.login("***@gmail.com", "PASSWORD") 

#Send the mail 
msg = "Hello!" 
# The /n separates the message from the headers 
server.sendmail("***@gmail.com", "***@gmail.com", msg) 
server.quit() 

这是我的错误:

server = smtplib.SMTP('smtp.gmail.com', 587) 
File "D:\Tools\Lib\smtplib.py", line 244, in __init__ 
    (code, msg) = self.connect(host, port) 
File "D:\Tools\Lib\smtplib.py", line 310, in connect 
    raise socket.error, msg 
    error: (10060, 'Operation timed out') 

回答

0

与Gmail有时Gmail会阻止检查从应用程序签名

enter image description here

+0

这会导致将返回一个错误的失败,他可能仍然需要做到这一点,但它不是什么导致此特别的错误。 – Ajurna