An html component cannot be sent with auth email messages
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- html, python
- Domain
- authentication, backend
Research direction
Start with the Mailer class in py4web/utils/mailer.py around lines 264-265, then trace the Auth class send method where params.message['body'] is handled. Reproduce an auth message with a two-item body and shortcuts such as {first_name} or {link}; done means both plain-text and HTML components are formatted and sent correctly.
Written by the indexing model from the issue text.
Description
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)
- Dominant language
- HTML
- Stars
- 319
- Forks
- 144
- Avg merge
- 6d 20h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from web2py/py4web
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
AXERA-TECH/ax-llm#75 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:security impact:ux-friction issue-rating: 🦞 diamond lobster P2
Difficulty 2/5 1-3 hours Newbie friendliness 84/100