我正在使用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
谢谢。
答案 0 :(得分:2)
您的防火墙阻止了连接。一旦删除脚本就可以使用。