libs package¶
Submodules¶
libs.emailer module¶
This module contains the logic for sending emails with the python email module.
-
libs.emailer.
logger
¶ The logger used to log information of module.
- Type
-
class
libs.emailer.
Email
[source]¶ Bases:
object
Class used for sending multipart emails (text and html).
This class can send emails by combining a text version and an HTML version of an email separately, then merge them with the MIMEMultipart(‘alternative’) instance. This is such that the email has two rendering options, such that in case HTML can’t be rendered successfully, the text version can still be rendered.
-
exception
libs.emailer.
EmailException
(message: str)[source]¶ Bases:
Exception
Class that is thrown when there is a Email error.
- Parameters
message (str) – Human readable string describing the exception.
libs.mailgun module¶
This module contains the logic for sending emails with Mailgun.
-
class
libs.mailgun.
Mailgun
[source]¶ Bases:
object
Class that handles the logic of sending emails by using the Mailgun API.
-
FROM_EMAIL
= 'do-not-reply@MAILGUN_DOMAIN'¶
-
FROM_TITLE
= 'Pricing service'¶
-
MAILGUN_API_KEY
= 'MAILGUN_API_KEY'¶
-
MAILGUN_DOMAIN
= 'MAILGUN_DOMAIN'¶
-
classmethod
send_mail
(email: List[str], subject: str, text: str, html: str) → requests.models.Response[source]¶ Sends an email.
- Parameters
- Returns
The response from the Mailgun API.
- Return type
Response
- Raises
MailgunException – If either the Mailgun API key or Mailgun domain failed to load. It will also be thrown if a bad API response was received from the post request.
-