email-stencils
Produce emails using Stencil templates.
Quick Start
Create a
stencil.TemplateLoader
import stencil loader = stencil.TemplateLoader(['./templates/'])
Write a template
{% block Subject %} Welcome to Nifty Service (TM) {% endblock %} {% block body %} Welcome! We're so happy you signed up to use Nifty Service (TM)! Please click here to activate your account: http://{{ activation_link }} {% endblock %} {% block html %} <h1>Welcome!</h2> <p>We're so happy you signed up to use Nifty Service ™!</p> Please click <a href="https://{{ activation_link }}">here</a> to activate your account! {% endblock %}
Generate the message
import email_stencil msg = email_stencil.build_message('email/welcome.email', {'activation_link': 'nifty.service/account/activate/'}, loader, ...)
Send the message!
import smtplib s = smtplib.SMTP('localhost') s.send_message(msg) s.quit()