API Reference
nti.mailer
nti.mailer.interfaces
Mailing interfaces.
This package is based upon both pyramid_mailer and repoze.sendmail,
but the relevant parts are re-exported from this package.
- class nti.mailer.interfaces.EmailAddressablePrincipal(context)[source]
Bases:
objectAn implementation of both
IEmailAddressableandIPrincipalthat combines both interfaces from something (a context) that is adaptable to both. Use this when the weight of the context is undesirable, such as during serialization (pickling), or when concurrency is a factor.This object copies the attributes from both interfaces into itself at construction time.
Implementation Details
Default mailer
Utility functions having to do with sending emails.
This module provides the nti.mailer.interfaces.ITemplatedMailer interface.
- nti.mailer._default_template_mailer.do_html_text_templates_exist(base_template, text_template_extension='.txt', package=None, _level=3)[source]
A preflight method for checking if templates exist. Returns a True value if they do.
- nti.mailer._default_template_mailer.create_simple_html_text_email(base_template, subject='', request=None, recipients=(), template_args=None, reply_to=None, attachments=(), package=None, cc=(), bcc=(), text_template_extension='.txt', context=<object object>, _level=3)[source]
Create a
pyramid_mailer.message.Messageby rendering the pair of templates to create a text and html part.- Parameters:
text_template_extension (str) – The filename extension for the plain text template. Valid values are “.txt” for Chameleon templates (this is the default and preferred version) and “.mak” for Mako templates. Note that if you use Mako, the usual
contextargument is renamed tonti_context, ascontextis a reserved word in Mako.package – If given, and the template is not an absolute asset spec, then the template will be interpreted relative to this package (and its templates/ subdirectory if no subdirectory is specified). If no package is given, the package of the caller of this function is used.
Changed in version 0.0.1: Now, if the subject is a
zope.i18nmessageid.Message, it will be translated.Changed in version 0.0.1: Added the context argument. If this argument is not supplied, the value of
request.contextwill be used. As a last resort,template_args['context'] will be used. (If both *context* or ``request.contextand a template argument value are given, they should be the same object.)
- nti.mailer._default_template_mailer.queue_simple_html_text_email(*args, **kwargs)[source]
Transactionally queues an email for sending. The email has both a plain text and an HTML version.
- Parameters:
text_template_extension – The filename extension for the plain text template. Valid values are “.txt” for Chameleon templates (this is the default and preferred version) and “.mak” for Mako templates. Note that if you use Mako, the usual
contextargument is renamed tonti_context, ascontextis a reserved word in Mako.- Returns:
The
pyramid_mailer.message.Messagewe sent.
Queue
See Console Programs for Mail Processing for information on how these are intended to be used.
Processors for repoze.sendmail, intended as a drop-in replacement
for the qp command line, using Amazon SES.
- class nti.mailer.queue.SESMailer(region='us-east-1')[source]
Bases:
objectThis object does not handle throttling or quata actions; see also
nti.app.bulkemail.process.
- class nti.mailer.queue.LoopingMailerProcess(mailer_factory, queue_path, sleep_seconds=120)[source]
Bases:
_AbstractMailerProcessA mailer processor that dumps the queue on a provided interval.
- class nti.mailer.queue.MailerWatcher(*args, **kwargs)[source]
Bases:
_AbstractMailerProcessA Mailer processor that watches for changes in the mail directory using gevent stat watchers.
- nti.mailer.queue.MailerProcess
Backwards compatibility alias
Deprecated since version 0.0.1: Use LoopingMailerProcess
VERP
Implementation of the nti.mailer.interfaces.IVERP protocol.