0
Getting this error "TypeError: _MailMixin.send() missing 1 required positional argument: 'message'" when trying to email a forgot password message via flask-mail. Feel like I'm following the model to a tee, but I'm obviously missing something.
Here is the relevant code:
Init.py
app.config['MAIL_SERVER']='smtp.mailtrap.io'
app.config['MAIL_PORT'] = 2525
app.config['MAIL_USERNAME'] = 'e1f8a312670b7d'
app.config['MAIL_PASSWORD'] = '7a56dfdd316300'
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USE_SSL'] = False
mail = Mail(app)
models.py
class User(db.Model,UserMixin):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(150), unique = True)
password = db.Column(db.String(150))
username = db.Column(db.String(150))
birthdate = db.Column(db.Date)
gender_id = db.Column(db.Integer)
createDate = db.Column(db.DateTime(timezone = true),default = func.now())
token = db.Column(db.String(32), nullable=False, unique=False)
notes = db.relationship('tbl_note')
views.py The code is failing on the line mail.send(msg)
if request.method =="POST":
user = User.query.filter_by(email = form.email.data).first()
if user:
#generate new token
token = str(uuid4()).replace('-','')
#update user token in db
user.token = token
db.session.add(user)
db.session.commit()
link = 'http://' + getenv('DOMAIN') + url_for(
'update_password',
email=my_user.email, token=token)
msg = Message('Password Reset Request',
sender='noreply@demo.com',
recipients=[user.email])
msg.body = 'To reset your password, visit the following link: ' + link +
'. If you did not make this request then simply ignore this email and no changes will be made.'
Mail.send(msg)
flash('We have sent an email to change your password. [Please check](https://apkhobby.com/total-conquest-mod-apk/) your Spam folder if not found.', category = 'success')
return redirect(url_for('auth.login'))
Top comments (0)