将烧瓶邮件与蓝图一起使用

时间:2019-08-08 07:13:38

标签: flask-mail

我正在使用烧瓶邮件。但是当我在烧瓶邮件的前端(react.js)中调用其余api时,出现此错误

  

“蓝图”对象没有属性“ config”

这是我的烧瓶邮件代码

from flask import Flask,Blueprint
from flask_mail import Mail, Message

app = Blueprint('app', __name__)
app.register_blueprint(url_prefix='/api/v1/SalesLead')
mail=Mail(app)

app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'myvar30@gmail.com'
app.config['MAIL_PASSWORD'] = '*****'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
mail = Mail(leadHistoryController)

@app.route("/")
def index():
   msg = Message('Sheraspace', sender = 'myvar30@gmail.com', recipients = ['jobaer.jhs@gmail.com'])
   msg.body = "Hello jh"
   mail.send(msg)
   return "Sent again"

if __name__ == '__main__':
   app.run(debug = True)

蓝图配置有什么解决方案吗?还是可以在不使用蓝图的情况下在前端使用rest api?

0 个答案:

没有答案