Flask-Security error: "ValueError: too many values to unpack"

Flask-Security error: "ValueError: too many values to unpack"

我已经设置了一个 flask-security 应用程序,但是我在创建用户和重置密码时遇到错误。

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1997, in __call__ 
  return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1985, in wsgi_app
  response = self.handle_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1540, in handle_exception
  reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1982, in wsgi_app
  response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1614, in full_dispatch_request
  rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1612, in full_dispatch_request
  rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1598, in dispatch_request
  return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python2.7/dist-packages/flask_securit /decorators.py", line 230, in wrapper
  return f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flask_security/views.py", line 118, in register
  user = register_user(**form.to_dict())
File "/usr/local/lib/python2.7/dist-packages/flask_security/registerable.py", line 41, in register_user
  'welcome', user=user, confirmation_link=confirmation_link)
File "/usr/local/lib/python2.7/dist-packages/flask_security/utils.py", line 401, in send_mail
  mail.send(msg)
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 492, in send
  message.send(connection)
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 427, in send
  connection.send(self)
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 188, in send
  self.host.sendmail(sanitize_address(envelope_from or message.sender),
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 105, in sanitize_address
  nm, addr = addr

ValueError: too many values to unpack    ValueError: too many values to unpack

我刚刚按照 https://pythonhosted.org/Flask-Security/quickstart.html#basic-sqlalchemy-application

的指南操作

我需要帮助找出问题所在。

这是我的电子邮件配置:

app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'devskovsted@gmail.com'
app.config['MAIL_PASSWORD'] = '**********'
app.config['MAIL_DEFAULT_SENDER'] = 'devskovsted@gmail.com'
mail = Mail(app)

/克雷斯滕

这是 flask-security utils ref this thread 中 send_mail 方法的一个已知问题。

这里更正了branch

一种解决方法是卸载 flask-security 并安装更新的 repo

pip install git+https://github.com/mattupstate/flask-security

当然,根据您的设置,您可能想要这样做 sudo pip install