{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% set events = collector.events %} {% if events.messages|length %} {% set icon %} {{ source('@WebProfiler/Icon/mailer.svg') }} {{ events.messages|length }} {% endset %} {% set text %}
Queued messages {{ events.events|filter(e => e.isQueued())|length }}
Sent messages {{ events.events|filter(e => not e.isQueued())|length }}
{% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { 'link': profiler_url }) }} {% endif %} {% endblock %} {% block menu %} {% set events = collector.events %} {{ source('@WebProfiler/Icon/mailer.svg') }} E-mails {% if events.messages|length > 0 %} {{ events.messages|length }} {% endif %} {% endblock %} {% block panel %} {% set events = collector.events %}

Emails

{% if not events.messages|length %}

No emails were sent.

{% else %}
{{ events.events|filter(e => e.isQueued())|length }} Queued
{{ events.events|filter(e => not e.isQueued())|length }} Sent
{% endif %} {% if events.transports|length > 1 %} {% for transport in events.transports %}

{{ transport }} transport

{{ _self.render_transport_details(collector, transport) }} {% endfor %} {% elseif events.transports is not empty %} {{ _self.render_transport_details(collector, events.transports|first, true) }} {% endif %} {% macro render_transport_details(collector, transport, show_transport_name = false) %}
{% set num_emails = collector.events.events(transport)|length %} {% if num_emails > 1 %}
{% for event in collector.events.events(transport) %} {% endfor %}
# Subject To Actions
{{ loop.index }} {{ event.message.headers.get('subject').bodyAsString() ?? '(No subject)' }} {{ (event.message.headers.get('to').bodyAsString() ?? '(empty)')|replace({'To:': ''}) }}
{% for event in collector.events.events(transport) %}
{{ _self.render_email_details(collector, transport, event.message, event.isQueued, show_transport_name) }}
{% endfor %} {% else %} {% set event = (collector.events.events(transport)|first) %} {{ _self.render_email_details(collector, transport, event.message, event.isQueued, show_transport_name) }} {% endif %}
{% endmacro %} {% macro render_email_details(collector, transport, message, message_is_queued, show_transport_name = false) %} {% if show_transport_name %}

Status: {{ message_is_queued ? 'Queued' : 'Sent' }}Transport: {{ transport }}

{% endif %} {% if message.headers is not defined %} {# render the raw message contents #} {{ source('@WebProfiler/Icon/download.svg') }} Download as EML file
{{ message.toString() }}
{% else %}

Email contents

{{ message.headers.get('subject').bodyAsString() ?? '(No subject)' }}

From: {{ (message.headers.get('from').bodyAsString() ?? '(empty)')|replace({'From:': ''}) }}

To: {{ (message.headers.get('to').bodyAsString() ?? '(empty)')|replace({'To:': ''}) }}

{% for header in message.headers.all|filter(header => (header.name ?? '') not in ['Subject', 'From', 'To']) %}

{{ header.toString }}

{% endfor %}
{% if message.attachments %}
{% set num_of_attachments = message.attachments|length %} {% set total_attachments_size_in_bytes = message.attachments|reduce((total_size, attachment) => total_size + attachment.body|length) %}

{{ source('@WebProfiler/Icon/attachment.svg') }} Attachments ({{ num_of_attachments }} file{{ num_of_attachments > 1 ? 's' }} / {{ _self.render_file_size_humanized(total_attachments_size_in_bytes) }})

    {% for attachment in message.attachments %}
  • {{ source('@WebProfiler/Icon/file.svg') }} {% if attachment.filename|default %} {{ attachment.filename }} {% else %} (no filename) {% endif %} ({{ _self.render_file_size_humanized(attachment.body|length) }}) Download
  • {% endfor %}
{% endif %} {% if message.htmlBody or message.textBody %}
{% if message.htmlBody %} {% set htmlBody = message.htmlBody() %}

HTML content

                                                    {%- if message.htmlCharset() %}
                                                        {{- htmlBody|convert_encoding('UTF-8', message.htmlCharset()) }}
                                                    {%- else %}
                                                        {{- htmlBody }}
                                                    {%- endif -%}
                                                

HTML preview

                                                    
                                                
{% endif %} {% if message.textBody %} {% set textBody = message.textBody() %}

Text content

                                                    {%- if message.textCharset() %}
                                                        {{- textBody|convert_encoding('UTF-8', message.textCharset()) }}
                                                    {%- else %}
                                                        {{- textBody }}
                                                    {%- endif -%}
                                                
{% endif %}
{% endif %}

MIME parts

{{ message.body().asDebugString() }}

Raw Message

{% endif %} {% endmacro %} {% macro render_file_size_humanized(bytes) %} {%- if bytes < 1000 -%} {{- bytes ~ ' bytes' -}} {%- elseif bytes < 1000 ** 2 -%} {{- (bytes / 1000)|number_format(2) ~ ' kB' -}} {%- else -%} {{- (bytes / 1000 ** 2)|number_format(2) ~ ' MB' -}} {%- endif -%} {% endmacro %} {% endblock %}