Refactor - Mail sending and EmailHandler

Open
#176 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@chgad is already working on this.

Since Nov 2, 2026.

  • #177 by @chgad — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start with the EmailHandler class: remove the unused self.environment in init, then make setup_smtp_server() populate self.server so get_or_create_smtp_server() works as a getter. Next, move the body and subject strings from each send() method into a new mail_templates.py, and add logging around the actual sending. Done when the checklist items are ticked and the existing mail tests still pass. Renaming the send_() methods and rewording the mails need maintainer input.

Written by the indexing model from the issue text.

Description

EmailHandler specific:
__init__():

  • Remove self.environment as it is unused

get_or_create_smtp_server()

  • method should be fully dynamic. For that _setup_smtp_server() should not return a server instance but populate the self.server attribute. Then get_or_create_smtp_server() calls it if server is not set or returns as if it was a getter.

All send_*() Methods:

  • create mail_templates.py file dedicated to store capitalized variables to store Mail body and subject strings
  • Move mail strings from the send_*() methods to the new mail_templates.py
  • Move Subject strings from the send_*() methods to the new mail_templates.py
  • If necessary, implement method handling formatting of mail strings
  • rename send_*() methods to more appropriate names where necessary.
  • Write short doc-strings to associate the methods with situations they are used in or the procedure they follow
  • Add error handling/logging to the actual sending of mails
  • Refactor/Rephrase mails
Dominant language
Python
Stars
0
Forks
0
Avg merge
29m
Merged PRs (30d)
14

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

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 ClockGU/clockwork-backend

All issues in ClockGU/clockwork-backend

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.