Modern python library for emails (debian packaging)
This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Sergey Lavrinenko dfb0ae57a7 setup.py fix 2013-08-18 01:39:34 +04:00
emails v0.1.9 2013-08-18 00:54:52 +04:00
.gitignore python-emails 0.1 2013-08-14 22:52:22 +04:00
.travis.yml exclude python 3.2 2013-08-18 00:49:39 +04:00
LICENSE Sorten license 2013-08-16 01:04:20 +04:00
MANIFEST.in setup.py fix 2013-08-18 01:39:34 +04:00
README.rst test_smtp fails on travis-ci 2013-08-16 19:55:09 +04:00
requirements.txt v0.1.9 2013-08-18 00:54:52 +04:00
setup.py setup.py fix 2013-08-18 01:39:34 +04:00

README.rst

python-emails
=============

Emails without pain for python.


What can you do:
----------------

Create message:

::

    import emails
    message = emails.html(html=open('letter.html'),
                          subject='Friday party',
                          mail_from=('Company Team', 'contact@mycompany.com'))


Attach files or inline images:

::

    message.attach( data=open('event.ics'), filename='Event.ics' )
    message.attach( data=open('image.png'), filename='image.png', content_disposition='inline' )

Add DKIM easily:

::

    message.dkim( key=open('my.key'), domain='mycompany.com', selector='newsletter' )



Templating:

::

    from emails.template import JinjaTemplate as T

    message = emails.html(subject=T('Payment Receipt No.{{no}}'),
                          html=T('<p>Dear {{account}} owner! This is a receipt for your subscription...'),
                          mail_from=('ABC', 'robot@mycompany.com'))

    message.send(to=('John Braun', 'jbraun@gmail.com'), render={'account': 'lavr', 'no':'141051906163'} )

Send without pain and (even) get response:

::

    SMTP = { 'host':'smtp.mycompany.com', 'port': 465, 'ssl': True }
    r = messages.send(to=('John Braun', 'jbraun@gmail.com'), smtp=SMTP)
    assert r.status_code == 250




One more thing
--------------

Library ships with fairy email-from-html loader.
Design email with less pain or even let designers make design:

::

    import emails
    URL = 'http://_youproject_.github.io/newsletter/2013-08-14/index.html'
    page = emails.loader.from_url(URL, css_inline=True, make_links_absolute=True)
    message = emails.html(html=page.html, ...)
    for mail_to in _get_maillist():
        message.send(to=mail_to)


Features
--------

-  Internationalization & Unicode bodies
-  DKIM signatures
-  HTML page loader & CSS inliner
-  Body and attachments http import
-  Body & headers preprocessors

TODO
----

- Python3
- Documentation
- More test coverage
- More accurate smtp session handling
- Some patches for pydkim performance (i.e. preload key once, not each time)
- More genius css inliner
- Catch all bugs
- ESP integration: Amazon SES, SendGrid, ...


How to Help
-----------

Library is under development and contributions are welcome!

1. Open an issue to start a discussion around a bug or a feature.
2. Fork the repository on GitHub and start making your changes to a new branch.
3. Write a test which shows that the bug was fixed.
4. Send a pull request. Make sure to add yourself to AUTHORS.


Background
----------

Library inspired by excellent python-requests and werkzeug library.
Some code is from my mailcube.ru experience.


.. image:: https://travis-ci.org/lavr/python-emails.png?branch=master
   :target: https://travis-ci.org/lavr/python-emails