API Docs


Invenio mail module.

class invenio_mail.ext.InvenioMail(app=None, stream=None)[source]

Invenio-Mail extension.

Extension initialization.

Mails are only printed to the stream if MAIL_SUPPRESS_SEND is True.

  • app – Flask application object.
  • stream – Stream to print emails to. Defaults to sys.stdout.

Flask application initialization.

The initialization will:

  • Set default values for the configuration variables.
  • Initialise the Flask mail extension.
  • Configure the extension to avoid the email sending in case of debug or MAIL_SUPPRESS_SEND config variable set. In this case, the email will be written in the stream configured in the extension.
Parameters:app – Flask application object.
static init_config(app)[source]

Initialize configuration.

Parameters:app – Flask application object.
invenio_mail.ext.print_email(message, app)[source]

Print mail to stream.

Signal handler for email_dispatched signal. Prints by default the output to the stream specified in the constructor of InvenioMail.

  • message – Message object.
  • app – Flask application object.



Celery task for sending emails.


Due to an incompatibility between MessagePack serialization and Message, support for attachments and dates is limited. Consult the tests for details.

Templated Messages

Template based messages.

class invenio_mail.api.TemplatedMessage(template_body=None, template_html=None, ctx=None, **kwargs)[source]

Siplify creation of templated messages.

Build message body and HTML based on provided templates.

Provided templates can use keyword arguments body and html respectively.

  • template_body – Path to the text template.
  • template_html – Path to the html template.
  • ctx – A mapping containing additional information passed to the template.
  • **kwargs – Keyword arguments as defined in flask_mail.Message.