QuickstartΒΆ

Easy API for sending e-mails based on smtplib and email.

Example

>>> from simple_email import Email, EmailClient
>>>
>>> # Note: EMAIL and EMAIL_AUTH refer to hypothetical environment variables
>>> # NEVER hard-code your auth in your code!
>>> email_client = EmailClient(login=EMAIL, password=EMAIL_AUTH,
                               host='smtp.office365.com', port=587)
>>>
>>> msg = Email(from_addr=email_client.login,
                to_addr="an_email_address@domain.com",
                subject="Sample Subject Line",
                body="Here's the body of the e-mail.",
                cc="another_email_address@domain.com")
>>>
>>> msg.add_attachment(b"Test bytes", "test_file.csv")
>>> msg.add_attachment_from_path(path="/some/path/file.ext")
>>>
>>> email_client.send(msg)