Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An html component cannot be sent with auth email messages #810

Open
hzarkoob opened this issue Sep 20, 2023 · 0 comments
Open

An html component cannot be sent with auth email messages #810

hzarkoob opened this issue Sep 20, 2023 · 0 comments

Comments

@hzarkoob
Copy link

hzarkoob commented Sep 20, 2023

The Mailer class indicates that to send html messages, the message body should be a 2-list or a 2-tuple. I tried setting auth.param.messages['reset_password']['body'] to a list, without success. After spending some time debugging, I think I found the root cause: Even if a list or tuple is provided as the message body, the params.message['body'] ends up being of class pluralize. It is params.message['body'].text that will contain the original list or tuple.

Also, a related issue. Both the plain text and HTML components of the body should be able to interpret shortcuts like {first_name} and {link} in the string.

Here is a quick change to the send method of the Auth class that fixes both the issues above. But it may not be the best solution, because it eliminates the original pluralize class.

if isinstance(message["body"].text, (list, tuple)):
   body = [element.format(**d) for element in message["body"].text]
else:
   body = message["body"].format(**d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant