Hi ! I'm trying to create a "contact" page on my website and I want to send mails using flask mail but I did some mistakes. I send you here the part of my code that may include an error. I hope you'll find it and tell me how to correct it !
code :
@app.route('/contact', methods=[ 'GET', 'POST'])
def contact():
form = ContactForm()
if request.method == 'POST':
if form.validate() == False:
flash('All fields are required.')
return render_template('contact.html', form=form)
else:
msg = Message('Mail', sender='anadress@gmail.com', recipients=['myadress@gmail.com'])
msg.body = """ From: %s mail: %s
Sujet: %s
message:
%s
""" % (form.name.data, form.email.data, form.subject.data, form.message.data)
mail.send(msg)
elif request.method == 'GET':
return render_template('contact.html', form=form)