TypeError:__init __()获得了意外的关键字参数'recepient'

时间:2019-12-11 14:44:48

标签: python-3.x flask-sqlalchemy flask-mail

从博客向收件人发送邮件时出现错误,但会引发错误。

@app.route('/contact', methods=['GET', 'POST'])
def contact():
if request.method == 'POST':
    name = request.form.get ('name')
    email = request.form.get('email')
    phone = request.form.get('phone')
    message = request.form.get('message')

    entry = Contact(name=name, email=email, phone_no=phone, \
                    date=datetime.now(), message=message)
    db.session.add(entry)
    db.session.commit()
    mail.send_message('A message from Blog' + name,
                      sender=email,
                      recepients=params['gail-user'],
                      body=message + "/n" + phone
                      )

    return render_template('contact.html',params=params)

1 个答案:

答案 0 :(得分:0)

the argument一词的拼写是recipients,而不是recepients。 flask-mail的Message类型(send_message与参数匹配)需要正确的拼写。