dkutils.smtp_api.sender module

class dkutils.smtp_api.sender.SMTP_Sender(host, user, password, port=587, use_tls=True)[source]

Bases: object

Class that can send emails using SMTP.

Parameters
  • host (str) – The hostname of the SMTP server

  • user (str) – The username to login to SMTP server

  • password (str) – The password to be used to login to the SMTP server

  • port (int) – The port of the SMTP server

  • use_tls (bool) – A boolean indicating whether or not to use TLS in communications with the server

do_send(message)[source]

Send an email message via SMTP :param message: An email message to be sent :type message: EmailMessage

dkutils.smtp_api.sender.create_message(sender, recipients, subject, plain_text=None, html_text=None, files=None, reply_addresses=None)[source]

Create a message for an email.

Parameters
  • sender (str) – Email address of the sender.

  • recipients (str|list) – Email address(es) of the receiver.

  • subject (str) – The subject of the email message.

  • plain_text (str) – The plain text of the email message.

  • html_text (str) – The html text of the email message.

  • files (str|list) – The path(s) of the file(s) to be attached.

  • reply_addresses (str|list) – Email address(es) replies should be sent to

Returns

An EmailMessage that can be sent

Return type

EmailMessage