References

Sender

class redmail.EmailSender(host, port, user_name=None, password=None)

Email sender

Parameters
  • host (str) – SMTP host address.

  • port (int) – Port to the SMTP server.

  • user (str, callable) – User name to authenticate on the server.

  • password (str, callable) – User password to authenticate on the server.

Examples

mymail = EmailSender(server="smtp.mymail.com", port=123)
mymail.set_credentials(
    user=lambda: read_yaml("C:/config/email.yaml")["mymail"]["user"],
    password=lambda: read_yaml("C:/config/email.yaml")["mymail"]["password"]
)
mymail.send(
    subject="Important email",
    html="<h1>Important</h1><img src={{ nice_pic }}>",
    body_images={'nice_pic': 'path/to/pic.jpg'},

)

Format Classes

class redmail.models.EmailAddress(address)

Format class for email addresses.

This class is useful manipulate the addresses in templates with minimal effort. More about email addresses from Wikipedia.

Parameters

address (str) – Email address as string.

class redmail.models.Error(content_type='text', exception=None)

Format class for errors including the exception and traceback.

Parameters
  • contet_type (str) – Content type for which the error is meant to be rendered on.

  • exception (Exception) – Exception object. If not passed, current stack trace is used.