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

Emailer: refactor, support bulk sending. #47

Merged
merged 2 commits into from
Mar 24, 2024
Merged

Emailer: refactor, support bulk sending. #47

merged 2 commits into from
Mar 24, 2024

Conversation

fuisl
Copy link
Owner

@fuisl fuisl commented Mar 24, 2024

Emailer refactor

This PR introduce class Emailer that will send email templates in bulks.

Usage

  1. Initialize an Emailer Object with path to template and qrcode path (use relative path).

(since this emailer is being used for sending out digital tickets, these information is fixed and neccessary. If you wish to use this emailer for other purposes, override the content() method for changing the content of the email.)

  1. Login to email service
    At this point, you can set test_email field to send out a test email to make sure that the system is working.
passkey = os.getenv("MAIL_PASSKEY")
emailer_obj.login(email, passkey, test_email="[email protected]")
  1. Send ticket
    You can either use send_one() or send_many(). Doctrings are included, explore the code for more information.
emailer_obj.send_one(info)  # dict
emailer_obj.send_many(infos)  # list of dicts

Do notice the contents of the input dictionary, the embedded content should be filled.

Handle exceptions

Some exceptions will be raised. (e.g. SMTPRecipentsRefused, etc.) and theses situations are not covered by the system. Should have a mechanism to check if ticket sent successfully. @nhientruong04

@fuisl fuisl requested a review from nhientruong04 March 24, 2024 08:34
@fuisl fuisl self-assigned this Mar 24, 2024
@fuisl fuisl added the bug Something isn't working label Mar 24, 2024
@fuisl fuisl merged commit 9023996 into master Mar 24, 2024
@fuisl fuisl deleted the email branch March 24, 2024 09:58
fuisl added a commit that referenced this pull request Apr 4, 2024
Emailer: refactor, support bulk sending.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant