Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Mailer.send() raises NameError: add_charset, charset_QP, Header and Encoders are not imported (1.20260805.0)

Open Beginner friendly
#1,069 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
92/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from web2py/py4web

All issues in web2py/py4web

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.