can only concatenate list (not "str") to list in flask

55 Views Asked by At

I am developing my own portfolio and about website and in contact form i want mail sender using flask but i am getting this error( can only concatenate list (not "str") to list).

I want that if anyone wanna send me message then i will get email.But i am facing the error.Need help.

@app.route("/contact",methods = ['GET', 'POST'])
def contact():
      if(request.method=='POST'):
            
            
          
           name = request.form.get('name')
           email = request.form.get('email')
          
           message = request.form.get('message')
           
           msg = Message('Hello', sender = email, recipients = "[email protected]")
           msg.body = message
           mail.send(msg)
      return render_template('contact.html')
1

There are 1 best solutions below

0
Henry On

The recipients argument expects a list which is why you get the error. Use this instead:

msg = Message('Hello', sender = email, recipients = ["[email protected]"])