flask-mail
flask-mail copied to clipboard
DEFAULT_MAIL_SENDER not seen
I have the default mail sender set as a config variable. I use the python debuggingserver on my development box, and Sendmail on the server.
I'm sending email from a celery task. If I call the procedures directly without using celery, everything works fine. If I use celery, it errors out because it doesn't see DEFAULT_MAIL_SENDER. I work around it by including this line: msg.sender = mail.app.config['DEFAULT_MAIL_SENDER'] Strangely, when I run it on the server, it works fine, even when called from a celery task.
This is probably due to Celery not having the Flask context (also you aren't in a request context). This is probably why it works when you run it on the server or directly, but when it's ran in celery mail.app.config isn't setup.
The config variable DEFAULT_MAIL_SENDER
has been renamed to MAIL_DEFAULT_SENDER
. See https://github.com/mattupstate/flask-mail/blob/master/flask_mail.py#L505. I've run into a similar problem as the documentation is not up to date.
@paveldedik that's because that's the old docs! We are trying to get that to redirect to Flask-Mail
and that might be the issue :|
@jamesonjlee Yes, you are absolutely right. Sorry, I didn't realize that. Unfortunately, first result on google search leads to the old docs.
@paveldedik yep, we are trying to remedy that :(
I don't know if the doc issue is solved, but it seems that bug can be closed.
Looks like the doc issue is still there. It took me a while to find this thread and was so confused because I was following the old documentation and couldn't find anything else.