Mixed content e-mails for Django made simple.
Project description
AS OF 2015-01-01 THIS PACKAGE IS NO LONGER SUPPORTED!
Easy sending of mixed content (html + plain) emails for Django.
Prerequisites
Django 1.5.+
Python 2.7.+, 3.3.+
Installation
Install in your virtual environment:
$ pip install django-lime
Add lime to your INSTALLED_APPS of your Django settings module:
>>> INSTALLED_APPS = ( >>> # ... >>> 'lime', >>> # ... >>> ) >>> >>> LIME_SITE_LOGO = 'img/logo.png' # Relative path to logo >>> LIME_SITE_TEAM = ugettext("Example site team") # Team name (see the base email template)
Copy the templates from lime to your main templates directory.
Define LIME_SITE_LOGO and LIME_SITE_TEAM variables in your settings module.
Make sure your django.contrib.sites.models.Site has data that makes sense, as site_name and domain values will be taken from there. Alternatively, you can define (override) those by defining the following variables in your settings module.
LIME_SITE_NAME
LIME_SITE_DOMAIN
Usage examples
Inherit your app templates from lime base templates or your own copy of the lime templates (copied to templates directory). By default the following parameters are passed to your template:
site_name: Taken from your django.contrib.sites.models.Site.
domain: Taken from your django.contrib.sites.models.Site
site_team: Site team name.
site_logo: Relative URL to site logo.
Sending of a mixed content e-mail is as simple as follows.
subject (str): E-mail subject.
from_email (str): From e-mail.
to (str or list): E-mail or a list of e-mails to send the e-mail to.
context (dict): Variables you want to have accessible in your e-mail templates.
plain_template (str): Plain template name.
html_template (str): HTML template name.
bcc (str or list): E-mail or a list of e-mails to send the e-mail to (as BCC).
>>> from lime import send_email >>> >>> send_email( >>> subject = _("You've got mail"), >>> from_email = 'ramzes.4@example.come', # From >>> to = 'someone.else@example.com', # To >>> context = { >>> 'date_submitted': datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S"), >>> 'url': 'http://example.com/check-this-fantastic-link.html', >>> 'full_name': 'John Doe', >>> 'from_name': 'Ramzes the 4th', >>> }, >>> plain_template = 'foo/emails/foo_test.txt', # Text template >>> html_template = 'foo/emails/foo_test.html' # HTML tempalte >>> )
Running example project
For a working example (including set-up Django environment) check the https://bitbucket.org/barseghyanartur/django-lime (example directory).
Go to example/example directory
$ cd example/example
Install requirements (in your virtual environment)
$ pip install -r requirements.txt
Copy local_settings.example to local_settings.py
$ cp local_settings.example local_settings.py
Create the database
$ ./manage.py syncdb
Run the project
$ ./manage.py runserver
License
GPL 2.0/LGPL 2.1
Support
For any issues contact me at the e-mail given in the Author section.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-lime-0.3.tar.gz
.
File metadata
- Download URL: django-lime-0.3.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6741a5d5cfb5f73edcec9857ddb3ef72730f19b334cdfc4e8a6a304cdd26de00 |
|
MD5 | 975cdfa323c3fa73bdf5afdc7bf4000a |
|
BLAKE2b-256 | 04357884cfa3dfb91cf3e32d3712b1369df41c7673afaec38b5b122b3ac918c9 |