看了菜鸟的教程,有这段代码:
mail = smtplib.SMTP("localhost")
然后就报错了。菜鸟的教程太老了,Python迭代这么快,根本跟不上。
把这个里面的参数去掉就好了。
mail = smtplib.SMTP()
可以看我的这篇文章,简单易懂:
Python 技术篇-用qq账号发送邮箱
报错代码:
Traceback (most recent call last):File "test.py", line 10, in <module>mail = smtplib.SMTP("localhost")File "D:\Python\lib\smtplib.py", line 251, in __init__(code, msg) = self.connect(host, port)File "D:\Python\lib\smtplib.py", line 336, in connectself.sock = self._get_socket(host, port, self.timeout)File "D:\Python\lib\smtplib.py", line 307, in _get_socketself.source_address)File "D:\Python\lib\socket.py", line 724, in create_connectionraise errFile "D:\Python\lib\socket.py", line 713, in create_connectionsock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
报错截图:
喜欢的点个赞?吧!