Flask-security: error when sending registration email (too many values to unpack (expected 2))

Created on 7 Dec 2017  路  2Comments  路  Source: mattupstate/flask-security

I am using the last version available with pip of flask-security and flask-mail.

When I try to register a patient I get:

registered_user = register_user(**register_user_form.to_dict())
File "/Users/k/3virtualenvs/p1/lib/python3.6/site-packages/flask_security/registerable.py", line 41, in register_user
  'welcome', user=user, confirmation_link=confirmation_link)
File "/Users/k/3virtualenvs/p1/lib/python3.6/site-packages/flask_security/utils.py", line 401, in send_mail
  mail.send(msg)
File "/Users/k/3virtualenvs/p1/lib/python3.6/site-packages/flask_mail.py", line 492, in send
  message.send(connection)
File "/Users/k/3virtualenvs/p1/lib/python3.6/site-packages/flask_mail.py", line 427, in send
  connection.send(self)
File "/Users/k/3virtualenvs/p1/lib/python3.6/site-packages/flask_mail.py", line 188, in send
  self.host.sendmail(sanitize_address(envelope_from or message.sender),
File "/Users/k/3virtualenvs/p1/lib/python3.6/site-packages/flask_mail.py", line 105, in sanitize_address
  nm, addr = addr
ValueError: too many values to unpack (expected 2)

However I get no errors when manually sending email:

from appl import mail, app
from flask_mail import Message

with app.app_context():
    msg = Message("Hello",
                  sender="[email protected]",
                  recipients=["[email protected]"])
    mail.send(msg)

Any hint will be very much appreciated!

Most helpful comment

This was due to not having set the SECURITY_EMAIL_SENDER config variable.

All 2 comments

This was due to not having set the SECURITY_EMAIL_SENDER config variable.

Ran into this today, so it's still behaving the same way. Surely this is a problem for which there could and should be a simple error message. The current message is completely opaque. Not sure this should have been closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

swedishmike picture swedishmike  路  5Comments

mafrosis picture mafrosis  路  7Comments

ochronus picture ochronus  路  4Comments

DerekDomino picture DerekDomino  路  5Comments

williamcheng-web picture williamcheng-web  路  4Comments