mentat.plugin.app.mailer module

This Mentat application plugin provides functions for sending emails. It is usable both in script and daemon modules.

Example usage

Using the plugin like in following way:

mentat.plugin.app.eventstorage.MailerPlugin()

That will yield following results:

  • The application object will have a mailerservice attribute containing reference to mailer service represented by mentat.plugin.app.MailerPlugin.

class mentat.plugin.app.mailer.MailerPlugin(settings=None)[source]

Bases: pyzenkit.baseapp.ZenAppPlugin

Implementation of Mentat application plugin providing functions for sending emails.

CONFIG_MAIL_ADMIN = 'mail_admin'
CONFIG_MAIL_BCC = 'mail_bcc'
CONFIG_MAIL_CC = 'mail_cc'
CONFIG_MAIL_FROM = 'mail_from'
CONFIG_MAIL_REPLY_TO = 'mail_reply_to'
CONFIG_MAIL_RETURN_PATH = 'mail_return_path'
CONFIG_MAIL_SUBJECT = 'mail_subject'
CONFIG_MAIL_TEST_MODE = 'mail_test_mode'
CONFIG_MAIL_TO = 'mail_to'
configure(app)[source]

Configure application. This method will be called from pyzenkit.baseapp.BaseApp._configure_plugins() and it further updates current application configurations.

This method is part of the setup stage of application`s life cycle.

Parameters

app – Reference to the parent application.

email_send(email_class, email_headers, email_params, flag_redirect=False)[source]

Create email according to given class, headers and parameters and send it via mail_sendmail() method.

Parameters
  • email_class (class) – Email class to be instantinated.

  • email_headers (dict) – Eplicitly specified email headers.

  • email_params (dict) – Additional email class constructor parameters.

  • flag_redirect (bool) – Redirect email from original recipient to administrator.

Returns

Constructed email object.

Return type

mentat.emails.base.BaseEmail

init_argparser(app, argparser, **kwargs)[source]

Callback to be called during argparser initialization phase.

init_config(app, config, **kwargs)[source]

Callback to be called during default configuration initialization phase.

static mail_sendmail(email)[source]

Send given email directly through local sendmail binary. This method is usefull for fire and forget scenarios.

Parameters

email (mentat.emails.base.BaseEmail) – Email object.

setup(app)[source]

Configure application. This method will be called from pyzenkit.baseapp.BaseApp._stage_setup_plugins() and it further updates current application configurations.

This method is part of the setup stage of application`s life cycle.

Parameters

app – Reference to the parent application.