我的简单 Flask 邮件应用程序可以在我的本地主机上运行而在 heroku 上不起作用

问题描述

应用在本地测试时发送电子邮件并正常工作 下面是我的配置

app = Flask(__name__)
app.config['sqlALCHEMY_DATABASE_URI'] = 'sqlite:///data.db'
app.config['sqlALCHEMY_TRACK_MODIFICATIONS'] = False
app.secret_key = 'xxxxxxxxxx'
app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT']= 587
app.config['MAIL_USE_TLS']= True
app.config['MAIL_USE_SSL']= False
app.config['MAIL_DEBUG']= True
app.config['TESTING']=False
app.config['MAIL_SUPPRESS_SEND'] = False
app.config['MAIL_USERNAME']='[email protected]'
app.config['MAIL_PASSWORD']='xxxxx'

这是我运行实际电子邮件功能的地方

def post(self):
    users = []
    data = USER.parser.parse_args()

    if User.find_by_username(data['username']):
        return {"message": "User with that username already exists."},400
    user = User(data['username'],data['password'],data['email'])
    users.append(user)

    message = Message('type in this to verify your email "random" ',sender ="xxxxx.com",recipients =[user.email])
    message.body = "na message be this"
    mail.send(message)

我不知道是否还有其他需要的信息

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)