第六章發送郵件用的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] 由於目標電腦積極拒絕,無法連線。
求大佬解決
等了一天沒有人來幫忙解決,心累,好在已經弄清楚怎麼回事了