webchanges.mailer module
Email handler.
- class webchanges.mailer.Mailer
Bases:
objectMailer class.
- send(msg)
Send a message.
- Parameters:
msg (EmailMessage) – The message to be sent.
- Raises:
NotImplementedError – Use a subclass of EmailMessage to send a message.
- Return type:
None
- static msg(from_email, to_email, subject, text_body, html_body=None, utf_8=True)
Create an Email object for a message.
- Parameters:
from_email (str) – The ‘From’ email address
to_email (str) – The ‘To’ email address
subject (str) – The ‘Subject’ of the email
text_body (str) – The body in text format
html_body (str | None) – The body in html format (optional)
utf_8 (bool) – Whether to format the message using SMTPUTF8 (optional)
- Return type:
EmailMessage
- class webchanges.mailer.SMTPMailer(smtp_user, smtp_server, smtp_port, tls, auth, insecure_password=None)
Bases:
MailerThe Mailer class for SMTP.
- Parameters:
smtp_user (str) – The username for the SMTP server.
smtp_server (str) – The address of the SMTP server.
smtp_port (int) – The port of the SMTP server.
tls (bool) – Whether tls is to be used to connect to the SMTP server.
auth (bool) – Whether authentication is to be used with the SMTP server.
insecure_password (str | None) – The password for the SMTP server (optional, to be used only if no keyring is present).
- smtp_user: str
- smtp_server: str
- smtp_port: int
- tls: bool
- auth: bool
- insecure_password: str | None = None
- send(msg)
Send a message via the SMTP server.
- Parameters:
msg (EmailMessage | None) – The message to be sent. Optional in order to allow server login testing.
- Return type:
None
- static msg(from_email, to_email, subject, text_body, html_body=None, utf_8=True)
Create an Email object for a message.
- Parameters:
from_email (str) – The ‘From’ email address
to_email (str) – The ‘To’ email address
subject (str) – The ‘Subject’ of the email
text_body (str) – The body in text format
html_body (str | None) – The body in html format (optional)
utf_8 (bool) – Whether to format the message using SMTPUTF8 (optional)
- Return type:
EmailMessage
- class webchanges.mailer.SendmailMailer(sendmail_path)
Bases:
MailerThe Mailer class to use sendmail executable.
- Parameters:
sendmail_path (str | Path)
- sendmail_path: str | Path
- send(msg)
Send a message via the sendmail executable.
- Parameters:
msg (EmailMessage) – The message to be sent.
- Return type:
None
- static msg(from_email, to_email, subject, text_body, html_body=None, utf_8=True)
Create an Email object for a message.
- Parameters:
from_email (str) – The ‘From’ email address
to_email (str) – The ‘To’ email address
subject (str) – The ‘Subject’ of the email
text_body (str) – The body in text format
html_body (str | None) – The body in html format (optional)
utf_8 (bool) – Whether to format the message using SMTPUTF8 (optional)
- Return type:
EmailMessage
- webchanges.mailer.smtp_have_password(smtp_server, from_email)
Check whether the keyring password is set for the email service.
- Parameters:
smtp_server (str) – The address of the SMTP server.
from_email (str) – The email address of the sender.
- Returns:
True if the keyring password is set.
- Return type:
bool
- webchanges.mailer.smtp_set_password(smtp_server, from_email)
Set the keyring password for the email service. Interactive.
- Parameters:
smtp_server (str) – The address of the SMTP server.
from_email (str) – The email address of the sender.
- Return type:
None