mailer.html.twig 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. {% extends '@WebProfiler/Profiler/layout.html.twig' %}
  2. {% block toolbar %}
  3. {% set events = collector.events %}
  4. {% if events.messages|length %}
  5. {% set icon %}
  6. {% include('@WebProfiler/Icon/mailer.svg') %}
  7. <span class="sf-toolbar-value">{{ events.messages|length }}</span>
  8. {% endset %}
  9. {% set text %}
  10. <div class="sf-toolbar-info-piece">
  11. <b>Queued messages</b>
  12. <span class="sf-toolbar-status">{{ events.events|filter(e => e.isQueued())|length }}</span>
  13. </div>
  14. <div class="sf-toolbar-info-piece">
  15. <b>Sent messages</b>
  16. <span class="sf-toolbar-status">{{ events.events|filter(e => not e.isQueued())|length }}</span>
  17. </div>
  18. {% endset %}
  19. {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { 'link': profiler_url }) }}
  20. {% endif %}
  21. {% endblock %}
  22. {% block head %}
  23. {{ parent() }}
  24. <style type="text/css">
  25. /* utility classes */
  26. .m-t-0 { margin-top: 0 !important; }
  27. .m-t-10 { margin-top: 10px !important; }
  28. /* basic grid */
  29. .row {
  30. display: flex;
  31. flex-wrap: wrap;
  32. margin-right: -15px;
  33. margin-left: -15px;
  34. }
  35. .col {
  36. flex-basis: 0;
  37. flex-grow: 1;
  38. max-width: 100%;
  39. position: relative;
  40. width: 100%;
  41. min-height: 1px;
  42. padding-right: 15px;
  43. padding-left: 15px;
  44. }
  45. .col-4 {
  46. flex: 0 0 33.333333%;
  47. max-width: 33.333333%;
  48. }
  49. /* small tabs */
  50. .sf-tabs-sm .tab-navigation li {
  51. font-size: 14px;
  52. padding: .3em .5em;
  53. }
  54. </style>
  55. {% endblock %}
  56. {% block menu %}
  57. {% set events = collector.events %}
  58. <span class="label {{ events.messages|length ? '' : 'disabled' }}">
  59. <span class="icon">{{ include('@WebProfiler/Icon/mailer.svg') }}</span>
  60. <strong>E-mails</strong>
  61. {% if events.messages|length > 0 %}
  62. <span class="count">
  63. <span>{{ events.messages|length }}</span>
  64. </span>
  65. {% endif %}
  66. </span>
  67. {% endblock %}
  68. {% block panel %}
  69. {% set events = collector.events %}
  70. <h2>Emails</h2>
  71. {% if not events.messages|length %}
  72. <div class="empty">
  73. <p>No emails were sent.</p>
  74. </div>
  75. {% endif %}
  76. <div class="metrics">
  77. <div class="metric">
  78. <span class="value">{{ events.events|filter(e => e.isQueued())|length }}</span>
  79. <span class="label">Queued</span>
  80. </div>
  81. <div class="metric">
  82. <span class="value">{{ events.events|filter(e => not e.isQueued())|length }}</span>
  83. <span class="label">Sent</span>
  84. </div>
  85. </div>
  86. {% for transport in events.transports %}
  87. <div class="card-block">
  88. <div class="sf-tabs sf-tabs-sm">
  89. {% for event in events.events(transport) %}
  90. {% set message = event.message %}
  91. <div class="tab">
  92. <h3 class="tab-title">Email {{ event.isQueued() ? 'queued' : 'sent via ' ~ transport }}</h3>
  93. <div class="tab-content">
  94. <div class="card">
  95. {% if message.headers is not defined %}
  96. {# RawMessage instance #}
  97. <div class="card-block">
  98. <pre class="prewrap" style="max-height: 600px">{{ message.toString() }}</pre>
  99. </div>
  100. {% else %}
  101. {# Message instance #}
  102. <div class="card-block">
  103. <div class="sf-tabs sf-tabs-sm">
  104. <div class="tab">
  105. <h3 class="tab-title">Headers</h3>
  106. <div class="tab-content">
  107. <span class="label">Subject</span>
  108. <h2 class="m-t-10">{{ message.headers.get('subject').bodyAsString() ?? '(empty)' }}</h2>
  109. <div class="row">
  110. <div class="col col-4">
  111. <span class="label">From</span>
  112. <pre class="prewrap">{{ (message.headers.get('from').bodyAsString() ?? '(empty)')|replace({'From:': ''}) }}</pre>
  113. <span class="label">To</span>
  114. <pre class="prewrap">{{ (message.headers.get('to').bodyAsString() ?? '(empty)')|replace({'To:': ''}) }}</pre>
  115. </div>
  116. <div class="col">
  117. <span class="label">Headers</span>
  118. <pre class="prewrap">{% for header in message.headers.all|filter(header => (header.name ?? '') not in ['Subject', 'From', 'To']) %}
  119. {{- header.toString }}
  120. {%~ endfor %}</pre>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. {% if message.htmlBody is defined %}
  126. {# Email instance #}
  127. <div class="tab">
  128. <h3 class="tab-title">HTML Content</h3>
  129. <div class="tab-content">
  130. <pre class="prewrap" style="max-height: 600px">
  131. {%- if message.htmlCharset() %}
  132. {{- message.htmlBody()|convert_encoding('UTF-8', message.htmlCharset()) }}
  133. {%- else %}
  134. {{- message.htmlBody() }}
  135. {%- endif -%}
  136. </pre>
  137. </div>
  138. </div>
  139. <div class="tab">
  140. <h3 class="tab-title">Text Content</h3>
  141. <div class="tab-content">
  142. <pre class="prewrap" style="max-height: 600px">
  143. {%- if message.textCharset() %}
  144. {{- message.textBody()|convert_encoding('UTF-8', message.textCharset()) }}
  145. {%- else %}
  146. {{- message.textBody() }}
  147. {%- endif -%}
  148. </pre>
  149. </div>
  150. </div>
  151. {% for attachment in message.attachments %}
  152. <div class="tab">
  153. <h3 class="tab-title">Attachment #{{ loop.index }}</h3>
  154. <div class="tab-content">
  155. <pre class="prewrap" style="max-height: 600px">{{ attachment.toString() }}</pre>
  156. </div>
  157. </div>
  158. {% endfor %}
  159. {% endif %}
  160. <div class="tab">
  161. <h3 class="tab-title">Parts Hierarchy</h3>
  162. <div class="tab-content">
  163. <pre class="prewrap" style="max-height: 600px">{{ message.body().asDebugString() }}</pre>
  164. </div>
  165. </div>
  166. <div class="tab">
  167. <h3 class="tab-title">Raw</h3>
  168. <div class="tab-content">
  169. <pre class="prewrap" style="max-height: 600px">{{ message.toString() }}</pre>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. {% endif %}
  175. </div>
  176. </div>
  177. </div>
  178. {% endfor %}
  179. </div>
  180. </div>
  181. {% endfor %}
  182. {% endblock %}