TODO Add description
Project description
CBTP
│ │└──Premailer (CSSs ares inlined)
│ └───Template
└─────Class-based (optional)
Installation
This package is not yet on PyPI. Download it from Github:
pip install --upgrade git+git://github.com/illagrenan/django-cbtp-email.git#egg=django-cbtp-email
Add ``django_cbtp_email`` to ``INSTALLED_APPS``:
INSTALLED_APPS = (
'django_cbtp_email',
)
Usage
Create custom mailer (e.g. in your_app/mailers.py):
from django_cbtp_email.mailer import Mailer
class TestMailer(Mailer):
template = "test_mail" # .html is added by default
subject = "Subject of test mail"
to = ["nobody@localhost"] # or override method get_recipients()
context = {
"title": "Hello world"
}
test_mailer = TestMailer()
text_mailer.attach_file("path/to/file_to_attach.PDF")
text_mailer.to.append("john@localhost")
test_mailer.send_message()
Create e-mail template (e.g. in your_app/templates/mail/test_email.html):
{% extends "email_base.html" %}
{% block content %}
<h1>{{ title }}</h1>
<p class="first">
Lorem ipsum...
</p>
<footer>
© 2015 ACME
</footer>
{% endblock %}
Content of email_base.html:
{% load mailing_tags %}
<!doctype html>
<html lang="cs">
<head>
<meta charset="UTF-8">
<title>Test mail</title>
<style>
/* This will be inlined */
h1 {
color: red;
}
</style>
{# This will be also inlined #}
{% css_direct "css/my_css.css" %}
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
You can specify type of rendered template by:
DEFAULT_TEMPLATE_TYPE = "html" # or "txt"
License
The MIT License (MIT)
Copyright (c) 2015–2017 Vašek Dohnal (@illagrenan)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_cbtp_email-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35dc90f201f5fbbf21638ccf1da58ded31c6a515c6141e31b0fba9561d4e7c75 |
|
MD5 | 032591177103722ea6cd31eb5f935241 |
|
BLAKE2b-256 | 1f8bada55b3e82117c1bcf273cc35278fde88c6bd1f5264d59f29ff1a514bf8b |