django-enhanced-emails 💌
🔋 Batteries-included emails for Django.
- Powerful templating engine
- Multipart emails by default (HTML + text)
- Web version rendering (with admin)
- Easy file attachment
- and more ...
Getting started
Simple setup
-
Install the package:
pipenv install django-enhanced-emails -
Create a new email class:
# myapp/emails.py from enhanced_emails import EnhancedEmail class WelcomeEmail(EnhancedEmail): subject = "Welcome to our site!" html_template = "emails/welcome.html"
<!-- myapp/templates/emails/welcome.html --> <strong>Welcome to our site {{first_name}}!</strong><br /> Best, The OurSite team
-
Instanciate an email and send it:
email = WelcomeEmail( to=[user.email], context={ "first_name": user.first_name } ) email.send()
-
✨ All done! Our user received something like:
Content-Type: multipart/alternative; boundary="===============7747654958126582044==" MIME-Version: 1.0 Subject: hello From: hello@oursite.com To: user@gmail.com Date: Wed, 11 Apr 2018 17:13:02 -0000 Message-ID: <152346678269.275.17989388690220812241@cf7f5f3375c9> --===============7747654958126582044== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Welcome to our site Elon! Best, The OurSite team --===============7747654958126582044== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit <strong>Welcome to our site Elon!</strong> Best, The OurSite team --===============7747654958126582044==--
Advanced setup (for web version rendering)
-
Add the
enhanced_emailsapp toINSTALLED_APPS:# settings.py INSTALLED_APPS = [ ... "enhanced_emails", ... ]
-
Add a new entry to
urlpatterns:# urls.py urlpatterns = [ path("admin/", admin.site.urls), path("emails/", include("enhanced_emails.urls")), ... ]
-
Use
WebVersionEnhancedEmailinstead ofEnhancedEmail:from enhanced_emails import WebVersionEnhancedEmail class WelcomeEmail(WebVersionEnhancedEmail): subject = "Welcome to our site!" html_template = "emails/welcome.html"
-
Use the
web_urlvariable in the email template:<!-- myapp/templates/emails/welcome.html --> <strong>Welcome to our site {{ first_name }}!</strong><br /> Best, The OurSite team<br /> <a href="{{ web_url }}">View in browser</a>
-
Instanciate an email and send it (notice that we need to pass the request as well now):
email = WelcomeEmail( to=[user.email], context={ 'first_name': user.first_name }, request=request ) email.send()
-
The email is visible in the admin and on the site! ✨
Development
- Deploy:
python setup.py sdist && twine upload dist/*
Metadata
Release files for django-enhanced-emails 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-enhanced-emails-0.0.7.tar.gz | 5.4 kB | Without provenance | Details for django-enhanced-emails-0.0.7.tar.gz |
Release files / django-enhanced-emails-0.0.7.tar.gz
| Download URL | django-enhanced-emails-0.0.7.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b41d2d15973ec445a3c42d81b54c3328d594450883c107eb9cba9987655e191a
|
|
BLAKE2b-256 checksum How to use checksums |
4b648bbcf34262c26c0cab0d7cb845647f14e8b33543d72b7b9d563d65887b21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6
|
Security for django-enhanced-emails 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.