使用flask-mail发送邮件报错问题记录
报错:OSError: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。
Exception in thread Thread-4:
Traceback (most recent call last):
File "E:\技术资料\接口框架\myMockServer\mytools\mail.py", line 23, in send_async_mail
mail.send(msg)
File "E:\技术资料\接口框架\mockenv\lib\site-packages\flask_mail.py", line 491, in send
with self.connect() as connection:
File "E:\技术资料\接口框架\mockenv\lib\site-packages\flask_mail.py", line 144, in __enter__
self.host = self.configure_host()
File "E:\技术资料\接口框架\mockenv\lib\site-packages\flask_mail.py", line 158, in configure_host
host = smtplib.SMTP(self.mail.server, self.mail.port)
File "c:\python\python35\Lib\smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "c:\python\python35\Lib\smtplib.py", line 335, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "c:\python\python35\Lib\smtplib.py", line 306, in _get_socket
self.source_address)
File "c:\python\python35\Lib\socket.py", line 711, in create_connection
raise err
File "c:\python\python35\Lib\socket.py", line 702, in create_connection
sock.connect(sa)
OSError: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。
仔细检查了一下,配置文件,原来是MAIL_SERVER填错,导致socket连接失败。
MAIL_SERVER = ‘mail.163.com’
改为:
MAIL_SERVER = ‘smtp.163.com’
邮件发送成功
报错:ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
Exception in thread Thread-4:
Traceback (most recent call last):
File "E:\技术资料\接口框架\myMockServer\mytools\mail.py", line 23, in send_async_mail
mail.send(msg)
File "E:\技术资料\接口框架\mockenv\lib\site-packages\flask_mail.py", line 491, in send
with self.connect() as connection:
File "E:\技术资料\接口框架\mockenv\lib\site-packages\flask_mail.py", line 144, in __enter__
self.host = self.configure_host()
File "E:\技术资料\接口框架\mockenv\lib\site-packages\flask_mail.py", line 158, in configure_host
host = smtplib.SMTP(self.mail.server, self.mail.port)
File "c:\python\python35\Lib\smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "c:\python\python35\Lib\smtplib.py", line 335, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "c:\python\python35\Lib\smtplib.py", line 306, in _get_socket
self.source_address)
File "c:\python\python35\Lib\socket.py", line 711, in create_connection
raise err
File "c:\python\python35\Lib\socket.py", line 702, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
报错:smtplib.SMTPAuthenticationError: (535, b’Error: authentication failed’)
Exception in thread Thread-4:
Traceback (most recent call last):
File "E:\技术资料\接口框架\myMockServer\mytools\mail.py", line 22, in send_async_mail
mail.send(msg)
File "E:\技术资料\接口框架\mockenv\lib\site-packages\flask_mail.py", line 491, in send
with self.connect() as connection:
File "E:\技术资料\接口框架\mockenv\lib\site-packages\flask_mail.py", line 144, in __enter__
self.host = self.configure_host()
File "E:\技术资料\接口框架\mockenv\lib\site-packages\flask_mail.py", line 165, in configure_host
host.login(self.mail.username, self.mail.password)
File "c:\python\python35\Lib\smtplib.py", line 729, in login
raise last_exception
File "c:\python\python35\Lib\smtplib.py", line 720, in login
initial_response_ok=initial_response_ok)
File "c:\python\python35\Lib\smtplib.py", line 641, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'Error: authentication failed')