You are here

swiftmailer.html.twig in Swift Mailer 8.2

The default template file for e-mails.

Available variables:

  • subject: The subject.
  • body: The message content.
  • is_html: True if generating HTML output, false for plain text.
  • message: The $message array created and used in the mail building procedure. Its content varies between cases, but typically contains at least the following elements:

    • id: The message identifier.
    • module: The module that handles the building of the message.
    • key: The key of the message.
    • to: The recipient email address.
    • from: The email address of the sender.
    • langcode: The langcode to use to compose the e-mail.
    • params: The message parameters.
  • base_url: The site base url including scheme, without trailing slash.

This template may be overriden by module and/or mail key, using any of the following template names:

  • swiftmailer.html.twig: global, used by default.
  • swiftmailer--mymodule.html.twig: only emails sent by the module "mymodule".
  • swiftmailer--mymodule--test.html.twig: only emails by the module "mymodule" with key "test".

File

templates/swiftmailer.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * The default template file for e-mails.
  5. *
  6. * Available variables:
  7. * - subject: The subject.
  8. * - body: The message content.
  9. * - is_html: True if generating HTML output, false for plain text.
  10. * - message: The $message array created and used in the mail building
  11. * procedure. Its content varies between cases, but typically contains at
  12. * least the following elements:
  13. * - id: The message identifier.
  14. * - module: The module that handles the building of the message.
  15. * - key: The key of the message.
  16. * - to: The recipient email address.
  17. * - from: The email address of the sender.
  18. * - langcode: The langcode to use to compose the e-mail.
  19. * - params: The message parameters.
  20. * - base_url: The site base url including scheme, without trailing slash.
  21. *
  22. * This template may be overriden by module and/or mail key, using any of the
  23. * following template names:
  24. * - swiftmailer.html.twig: global, used by default.
  25. * - swiftmailer--mymodule.html.twig: only emails sent by the module "mymodule".
  26. * - swiftmailer--mymodule--test.html.twig: only emails by the module
  27. * "mymodule" with key "test".
  28. *
  29. * @see template_preprocess()
  30. * @see template_preprocess_swiftmailer()
  31. *
  32. * @ingroup themeable
  33. */
  34. #}
  35. {% if is_html %}
  36. <html>
  37. <head>
  38. <style type="text/css">
  39. table tr td {
  40. font-family: Arial;
  41. font-size: 12px;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <div>
  47. <table width="800px" cellpadding="0" cellspacing="0">
  48. <tr>
  49. <td>
  50. <div style="padding: 0px 0px 0px 0px;">
  51. {{ body }}
  52. </div>
  53. </td>
  54. </tr>
  55. </table>
  56. </div>
  57. </body>
  58. </html>
  59. {% else %}
  60. {{ body }}
  61. {% endif %}