Print mail to stream.

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

    :param message: Message object.
    :param app: Flask application object.

def print_email(message, app):
    """Print mail to stream.

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

    :param message: Message object.
    :param app: Flask application object.
    """
    invenio_mail = app.extensions['invenio-mail']
    with invenio_mail._lock:
        invenio_mail.stream.write(
            '{0}\n{1}\n'.format(message.as_string(), '-' * 79))
        invenio_mail.stream.flush()