{% import os %} {% import mailapp %} {% from gramex.cache import reload_module %} {% set reload_module(mailapp) %} {% from gramex.services import info %} {% set selected = handler.get_arg('alert', None) %}
{% for name, alert in info.alert.items() %} {{ name }} {% end %}
{% if selected is None %}

Previewing command line emails from ...

Select an email to preview.

{% elif selected not in info.alert %}
Cannot find alert named {{ selected }}
{% else %} {% set results = [] %} {% set info.alert[selected].function(callback=lambda **msg: results.append(msg)) %} {% for result in results %} {% for key, val in result.items() %} {% if key not in {'html', 'body', 'images', 'attachments'} %} {% end %} {% end %} {% set mailapp.cidmap.update(result.get('images', {})) %} {% if 'attachments' in result %} {% end %}
{{ key }} {{ result[key] }}
attachments {% for attachment in result['attachments'] %}
  • {{ os.path.split(attachment)[-1] }}
  • {% end %}
    {% if 'html' in result %}{% raw result['html'].replace('cid:', 'cid/') %}{% end %} {% if 'body' in result and 'html' in result %}
    {% end %} {% if 'body' in result %}
    {% raw result['body'] %}
    {% end %} {% end %} {% end %}