我一直收到以下错误:
error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
是否有人对可能导致错误的原因有任何建议,以及如何解决此问题?
import smtplib
msg = "\nHello!\nThe following servers have an error........"
# The /n separates the message from the headers
server = smtplib.SMTP('smtp.gmail.com',587) ## Try 587 or 2525
server.ehlo()
server.starttls()
#Next, log in to the server
try:
server.login("useremail", "password")
print " you are logged into your account"
except:
print "Username or password is incorrect"
#Send the mail
try:
server.sendmail("useremail", "recipient", msg)
print "Congratulations! Email was sent."
except:
print "email could not send"
server.close()
答案 0 :(得分:0)
也许尝试发送一封包含SqlLite Fiddle Demo的简单电子邮件,可以通过默认设置进行保存:
SELECT
a.id,
a.title,
'[' ||
GROUP_CONCAT(
'{"id":' ||
b.id ||
', "name":"' ||
b. `name` ||
'", "number":"' ||
b.number ||
'"}'
) || ']'
AS people
FROM
contact_group AS a
LEFT JOIN contact_list AS b ON a.id = b.gID
GROUP BY
a.id,
a.title
您可能必须先使用以下方式安装它:
import yagmail
yagmail.SMTP('username', 'password').send(contents = msg)