# 补充:qq邮箱授权码有使用期限,如果超过期限也可能出现下面错误!
Exception in thread Thread-2:
Traceback (most recent call last):
File "c:\users\82055\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "c:\users\82055\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "H:\PyCoding\project\unrealblue-blog-master\app\email.py", line 18, in send_async_mail
mail.send(msg)
File "H:\PyCoding\project\blog\lib\site-packages\flask_mail.py", line 491, in send
with self.connect() as connection:
File "H:\PyCoding\project\blog\lib\site-packages\flask_mail.py", line 144, in __enter__
self.host = self.configure_host()
File "H:\PyCoding\project\blog\lib\site-packages\flask_mail.py", line 165, in configure_host
host.login(self.mail.username, self.mail.password)
File "c:\users\82055\appdata\local\programs\python\python36\Lib\smtplib.py", line 730, in login
raise last_exception
File "c:\users\82055\appdata\local\programs\python\python36\Lib\smtplib.py", line 721, in login
initial_response_ok=initial_response_ok)
File "c:\users\82055\appdata\local\programs\python\python36\Lib\smtplib.py", line 642, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'Error: \xc7\xeb\xca\xb9\xd3\xc3\xca\xda\xc8\xa8\xc2\xeb\xb5\xc7\xc2\xbc\xa1\xa3\xcf\xea\xc7\xe9\xc7\xeb\xbf\xb4: http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256')
上面的错误看着很恼人,主要是太长了,内容也七七八八奇奇怪怪的,其实不是上面大问题,我是在博客注册时用到了邮箱验证,web框架用的flask,虽然 Python 标准库中的 smtplib 包可用在 Flask 程序中发送电子邮件,但包装了 smtplib 的 Flask-Mail 扩展能更好地和 Flask 集成,所以我的邮件发送用的 flask-mail模块。
其实我们静下心来慢慢看这个错误,其实不难,SMTPAuthenticationError == SMTP-认证错误
,而且最后还给了个链接我们:
http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256
MAIL_PASSWORD
这个参数是我们自己的邮箱密码,其实不是,我们通过python来发送邮件,实际是调用了qq邮箱的api,属于第三方客户端,所以我们这里要给的password是发送邮箱的
授权码
,至于授权码怎么获取, 点击这里,跟着步骤一步步来就行啦!