{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block head %} {{ parent() }} {% endblock %} {% 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') }} Emails {% 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.getSubject() ?? '(No subject)' }} {{ event.message.getTo()|map(addr => addr.toString())|join(', ')|default('(empty)') }}
{% 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.getSubject() ?? '(No subject)' }}

From: {{ message.getFrom()|map(addr => addr.toString())|join(', ')|default('(empty)') }}

To: {{ message.getTo()|map(addr => addr.toString())|join(', ')|default('(empty)') }}

{% for header in message.headers.all|filter(header => (header.name ?? '')|lower 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, 0) %}

{{ 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 %}
{% set textBody = message.textBody %} {% set htmlBody = message.htmlBody %}

Text content

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

The text body is empty.

{% endif %}
{% if htmlBody %}

HTML preview


                                            
{% endif %}

HTML content

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

The HTML body is empty.

{% 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 %}