第六章发送邮件用的QQ邮箱,用了各种办法都没用
#!/usr/bin/env python
#coding: utf-8
from flask import Flask
from flask_mail import Mail,Message
import os
app = Flask(__name__)
mail = Mail(app)
app.config['DEBUG'] = True
app.config['MAIL_SERVER'] = 'smtp.qq.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = '1434069**1@qq.com'
app.config['MAIL_PASSWORD'] = 'kfzroq**youejhee'
app.config['MAIL_DEFAULT_SENDER']='1434069**1@qq.com'
@app.route('/')
def index():
msg = Message(subject='Email test by flask-email',sender="1434069**1@qq.com",recipients=['har**hi@163.com'])
msg.body = 'hello'
msg.html = '<b>测试Flask发送邮件<b>'
mail.send(msg)
# return '<h1>邮件发送成功</h1>'
if __name__ == '__main__':
app.run(debug=True)
代码如上,这是拿出来测试邮件的代码
这是QQ邮箱的设置,端口25/465/587都试过了,USER_NAME @qq.com/,带不带@.com也试过了,USER_PASSWORD,原密码,授权码也都试过了
错误如下:
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
求大佬解决
等了一天没有人来帮忙解决,心累,好在已经弄清楚怎么回事了