使用python发送邮件会出错

问题描述 投票:1回答:1

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

我遇到了错误

我的代码是

import smtplib

smtp_server = smtplib.SMTP('smtp.gmail.com', 587)
smtp_server.ehlo()
smtp_server.starttls()
smtp_server.login('[email protected]', '587')

smtp_server.sendmail('[email protected]', '[email protected]', '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

提前致谢。

python email smtp
1个回答
2
投票

你的防火墙会阻止连接。一旦删除脚本将工作。

© www.soinside.com 2019 - 2024. All rights reserved.