Django mail system ported to tornado and made asynchronous
Python Perl
Switch branches/tags
Nothing to show
Pull request Compare This branch is 2 commits ahead, 9 commits behind equeny:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
debian
tornadomail
.gitignore
README.md
index.html
setup.py
test.py
testproject.py

README.md

Tornado mail

Asynchronous email sending(SMTP) library for Tornado. Port of django.mail.

Installation

Using pip: pip install tornadomail From source: git clone git://github.com/equeny/tornadomail.git; cd tornadomail; python setup.py install

Usage

EmailMessage, EmailMultiAlternatives are almost identical to django classes, except send function is async and can receive callback argument.

from tornadomail.message import EmailMessage, EmailMultiAlternatives
from tornadomail.backends.smtp import EmailBackend


class Application(tornado.web.Application):
    @property
    def mail_connection(self):
        return EmailBackend(
            'smtp.gmail.com', 587, '<your google mail>', '<your google password>',
            True
        )

class MainHandler(tornado.web.RequestHandler):

    @property
    def mail_connection(self):
        return self.application.mail_connection

    def get(self):
        self.render("index.html")

    def post(self):

        def _finish(num):
            print 'sended %d message(s)' % num
            self.render("index.html")

        message = EmailMessage(
            self.get_argument('subject'),
            self.get_argument('message'),
            '<your google mail>',
            [self.get_argument('email')],
            connection=self.mail_connection
        )
        message.send()#callback=_finish)
        self.render("index.html")

Requirements

The following two python libraries are required

Issues

Please report any issues via github issues