This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

An easy django email backend to send email using Submail’s python Mail API.

Requirements

Django >= 1.8. Django with other versions are not tested.

Installation

Install the backend from PyPI:

pip install django-submail

Add the following lines to your project’s settings.py or your local settings:

EMAIL_BACKEND = "smbackend.SubmailBackend"
SUBMAIL_APP_ID = "Your Submail APPID"
SUBMAIL_APP_KEY = "Your Submail APPKey"

Usage

If you use send_mail method, you can simply do it by, for example:

from django.core.mail import send_mail

send_mail(
    "Your Subject",
    "This is a pure text email body.",
    "Dong Zhuang <hello@foo.com>",
    ["dongzhuang@bar.com"]
    )

If you want to use the EmailMessage class, then:

from django.core.mail import EmailMessage

mail = EmailMultiAlternatives(
    subject="Your Subject",
    body="This is a pure text email body.",
    from_email="Dong Zhuang <hello@example.com>",
    to=["dongzhuang@foo.com"],
    headers={"Reply-To": "dongzhuang@bar.com"}
    )

mail.send()

If you want to use the EmailMultiAlternatives class, then:

from django.core.mail import EmailMultiAlternatives

mail = EmailMultiAlternatives(
    subject="Your Subject",
    body="This is a pure text email body.",
    from_email="Dong Zhuang <hello@example.com>",
    to=["dongzhuang@foo.com"],
    headers={"Reply-To": "dongzhuang@bar.com"}
    )

mail.attach_alternative(
    "<p>This is an HTML email body</p>", "text/html")

mail.send()

Sometimes you need to send some other emails using APPID other than the default SUBMAIL_APP_ID set in settings.py, you can use add SUBMAIL_APP_ID and SUBMAIL_APP_KEY keys in header, for example:

from django.core.mail import EmailMultiAlternatives

mail = EmailMultiAlternatives(
  subject="Your Subject",
  body="This is a simple text email body.",
  from_email="Dong Zhuang <hello@example.com>",
  to=["dongzhuang@foo.com"],
  headers={
    "Reply-To": "dongzhuang@bar.com",
    "SUBMAIL_APP_ID": settings.ANOTHER_APP_ID,
    "SUBMAIL_APP_KEY": settings.ANOTHER_APP_KEY}
)

mail.attach_alternative("<p>This is an HTML email body</p>", "text/html")

mail.send()

DEMO

A demo is included in the repository, you can clone the git and run it locally.

You can optionally run the demo using virtualenv.

pip install virtualenv
virtualenv venv
venv/scripts/activate

Then

pip install django
pip install django-submail
git clone https://github.com/dzhuang/django-submail.git
cd django-submail/demo
python manage.py migrate

Make a copy of example local settings:

cd demo
cp settings_local.py.example settings_local.py
vi settings_local.py

Edit params in settings_local.py according to your own submail app, and edit demo/test_smbackend/views.py if necessary, then run the dev server:

cd ..
python manage.py runserver

and visit http://127.0.0.1:8000 to see the result.

TODOs

  • Support Submail’s mail/xsend API
  • Support Submail’s addressbook

LICENSE

The MIT License.

Contribution

Django-submail is wholly open source and welcomes contributions of any kind. Feel free to either extend it, report bugs, or provide suggestions for improvements. The author of can be contacted at dzhuang.scut@gmail.com.

Release History

Release History

1.1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1.dev0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_submail-1.1.0-py2.7.egg (36.6 kB) Copy SHA256 Checksum SHA256 2.7 Egg Sep 18, 2016
django_submail-1.1.0-py2.py3-none-any.whl (20.9 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Sep 18, 2016
django-submail-1.1.0.tar.gz (10.3 kB) Copy SHA256 Checksum SHA256 Source Sep 18, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting