Module reahl.mailutil.mail

Utility classes for sending simple email messages.


class reahl.mailutil.mail.MailMessage(from_address, to_addresses, subject, rst_message, charset='utf-8')

Represents an email message, with one part containing plain text (presumed to be ReST), and the other an HTML representation of the same message.

  • from_address – The “from” email address
  • to_addresses – A list of “to” email addresses
  • subject – The subject line
  • rst_message – A message, expressed as a string containing ReStructured Text
  • charset – The charset of rst_message

Returns the message as ASCII-encoded string for sending.


class reahl.mailutil.mail.Mailer(smtp_host='localhost', smtp_port=8025, smtp_user=None, smtp_password=None, smtp_use_initial_encrypted_connection=False, smtp_upgrade_initial_connection_to_encrypted=False, smtp_keyfile=None, smtp_certfile=None)

A proxy for a remote SMTP server.

  • smtp_host – The host to connect to.
  • smtp_port – The port to connect to.
  • smtp_user – The username to use (if specified) for authentication.
  • smtp_password – The password to authenticate with the smtp host.
  • smtp_use_initial_encrypted_connection – If True, connect to the server using a secure connection (use with smtps)
  • smtp_upgrade_initial_connection_to_encrypted – If True, connects to the server unencrypted, but then upgrade to a secure connection using STARTTLS (use with submission or smtp)
  • smtp_keyfile – Keyfile to use for identifying the local end of the connection.
  • smtp_certfile – Certfile to use for identifying the local end of the connection.
classmethod from_context()

Returns a Mailer, using the system configuration.


Sends message (a MailMessage) to the connected SMTP server.