Skip to content

PauloPhagula/send-mail

Repository files navigation

send_mail

https://travis-ci.org/dareenzo/send-mail.svg?branch=master https://coveralls.io/repos/github/dareenzo/send-mail/badge.svg?branch=master

e-mail sending module.

Code Example

PLAINTEXT_EMAIL = 'Yo...'
HTML_EMAIL = '<html>...'

send_mail(
    '[AwesomeApp] very descriptive subject',
    message=PLAINTEXT_EMAIL,
    html_message=HTML_EMAIL,
    to=[('To Example', '[email protected]'), '[email protected]'],
    cc='[email protected], [email protected]',
    bcc=['[email protected]', ('You Know Who', '[email protected]')],
    sender=('AwesomeApp', '[email protected]'),
    reply_to='[email protected], [email protected]',
    attachments=['/full/path/to/attachment.ext'],
    custom_headers={'X-Mailer': 'SendMail'}
)

Attention!

In order to send the e-mail the function requires your server details. You can put these details in SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, SMTP_USE_SSL & SMTP_USE_TLS environment variables, or pass them as keyword arguments without the smpt_ prefix.

Installation

You can install this module directly from github with

pip install -e git+https://github.com/dareenzo/[email protected]#egg=send_mail

Testing

Unit tests are provided with the code and you can run them by copying the .env.example file into a .env file on the root of the project.

The .env file contains the required environment variables for the module. So update it with your own settings. These setting will be read by the cheap_dot_env function into environment variables before each test so that the send_mail function can work properly

cp .env.example .env
# edit .env file with your mail settings
pip install -r requirements/test.txt
tox

Documentation Generation

# edit documentation in _docs
cd _docs
make singlehtml
cd ..
cp -fR _docs/_build/singlehtml/* docs/

Copyright & License

Code and documentation are available according to the MIT License.

See the LICENSE file for details.