net.smtp
¶
Module Contents¶
Functions¶
|
Send an email with stmplib. |
|
Send an e-mail message. |
Attributes¶
- net.smtp.logger¶
- net.smtp.system_sendmail_fallback = False¶
- net.smtp.sendmail(from_email: str, to_emails: list[str], mail_as_string: str, smtp_servers: collections.abc.Sequence[str], max_size: int = 40, message_id: str | None = None) bool ¶
Send an email with stmplib.
Fallback to /usr/lib/sendmail or /usr/sbin/sendmail if
e3.net.smtp.system_sendmail_fallback
is set to True (default False).- Parameters:
from_email – the address sending this email (e.g. user@example.com)
to_emails – A list of addresses to send this email to.
mail_as_string – the message to send (with headers)
smtp_servers – list of smtp server names (hostname), in case of exception on a server, the next server in the list will be tried
max_size – do not send the email via smptlib if bigger than ‘max_size’ Mo.
message_id – the message id (for debugging purposes)
- Returns:
boolean (sent / not sent)
We prefer running smtplib so we can manage the email size. We run sendmail in case it fails, assuming the max_size on the system is high enough - the advantage of sendmail is that it queues the email and retries a few times if the target server is unable to receive it.
- net.smtp.send_message(from_email: str, to_emails: list[str], subject: str, content: str, smtp_servers: list[str]) None ¶
Send an e-mail message.
- Parameters:
from_email – the address sending this email (e.g. user@example.com)
to_emails – A list of addresses to send this email to
subject – the e-mail’s subject
content – the e-mail’s content