Mailer.send() raises NameError: add_charset, charset_QP, Header and Encoders are not imported (1.20260805.0)
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 92/100
Research direction
Open py4web/utils/mailer.py and inspect the undefined names reported by pyflakes: add_charset, charset_QP, Header, and Encoders. Reproduce the failure with the Mailer.send() example, then verify that normal messages and attachment handling no longer raise NameError and that the UTF-8 quoted-printable message is built correctly.
Written by the indexing model from the issue text.
Description
Description
In py4web 1.20260805.0 (the latest release on PyPI), and on current master, Mailer.send() raises NameError on every call, so no email can be sent. That includes the emails sent by Auth.
py4web/utils/mailer.py uses four names that it never imports:
| Line | Name |
|---|---|
| 391 | add_charset |
| 391 | charset_QP |
| 395 | Header |
| 235 | Encoders (attachments only) |
They used to come from from pydal._compat import *. Commit 1df05c3 ("last py4web version before the pydal refactor") removed that import without replacing those four names. pyflakes py4web/utils/mailer.py reports them as undefined.
Steps to reproduce
from py4web.utils.mailer import Mailer
m = Mailer(server="logging", sender="[email protected]")
m.send("[email protected]", "subject", "body")
Actual result
File ".../py4web/utils/mailer.py", line 391, in send
add_charset("utf-8", charset_QP, charset_QP, "utf-8")
^^^^^^^^^^^
NameError: name 'add_charset' is not defined
Suggested fix
Add the missing imports to py4web/utils/mailer.py:
from email import encoders as Encoders
from email.charset import QP as charset_QP
from email.charset import add_charset
from email.header import Header
I am working around it at the application level by injecting these names into py4web.utils.mailer. With that in place, send() builds a correct quoted-printable UTF-8 message and hands it to SMTP.
Environment
- py4web 1.20260805.0
- pydal 20260520.0
- Python 3.12 (Linux and Google App Engine)
- Dominant language
- HTML
- Stars
- 319
- Forks
- 144
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 2/5 1-3 hours Newbie friendliness 75/100
-
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
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 3 days
-
backend dev experience good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cuttle-cards/cuttle#1401 ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
btclib-org/btclib-wallet#267 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
langchain-ai/langmem#194 ·