使用python发送邮件出现错误

时间:2018-08-30 11:05:58

标签: python email smtp

我正在使用python和SMTP发送邮件

我遇到了错误

我的代码是

import smtplib

smtp_server = smtplib.SMTP('smtp.gmail.com', 587)
smtp_server.ehlo()
smtp_server.starttls()
smtp_server.login('something@gmail.com', '587')

smtp_server.sendmail('pybitesblog@gmail.com', 'recipient@gmail.com', 'Subject: Happy Australia Day!\nHi Everyone! Happy  Day! Cheers, Julian')

smtp_server.quit()
print('Email sent successfully')

和  错误是

error: [Error 10061] No connection could be made because the target machine actively refused it

error: [error 10013] An attempt was made to access a socket in a way forbidden by its access permissions

谢谢。

1 个答案:

答案 0 :(得分:2)

您的防火墙阻止了连接。一旦删除脚本就可以使用。