Postoffice API: Events and BodyRenderer
Last updated on
30 November 2022
The \Symfony\Component\Mailer\Event\MessageEvent
event is dispatched before an e-mail is handed off to the MTA. Postoffice comes with a set of subscribers for this event. Subscribing to the MessageEvent
is the principal extension point for contrib and custom code.
When adding subscribers, it is recommended to choose the priority according to their purpose:
- Positive priority for subscribers to be run before any
BodyRenderer
. - Priority 0 for any subscriber invoking a
BodyRenderer
. - Priority -50 for twig extensions.
Module | Priority |
---|---|
Module: Postoffice, Service: postoffice.body_subscriber Class: \Symfony\Component\Mailer\EventListener\MessageListener Invokes postoffice.body_renderer in order to render the body of messages implementing the \Drupal\postoffice\Email\ThemedEmailInterface |
0 |
Module: Postoffice File, Service: postoffice_file.attachment_subscriber Class: \Drupal\postoffice_file\EventSubscriber\FileAttachmentSubscriber Attaches files supplied by the postoffice_file_attach_uri and postoffice_file_attach_entity twig filters. |
-50 |
Module: Postoffice Image, Service: postoffice_image.image_embed_subscriber Class: \Drupal\postoffice_image\EventSubscriber\ImageEmbedSubscriber Embeds images supplied by the postoffice_image_embed twig filter. |
-50 |
Module: Postoffice Twig, Service: postoffice_twig.subject_subscriber Class: \Drupal\postoffice_twig\EventSubscriber\TwigSubjectSubscriber Sets the subject supplied by the postoffice_subject twig filter. |
-50 |
Module: Postoffice Twig, Service: postoffice_twig.text_body_subscriber Class: \Drupal\postoffice_twig\EventSubscriber\TwigTextBodySubscriber Sets the text body supplied by the postoffice_text_body twig filter. |
-50 |
Module: Postoffice Html2Text, Service: postoffice_html2text.message_subscriber Class: \Drupal\postoffice_html2text\EventSubscriber\MessageSubscriber Generates a plain text part for every HTML message. |
-100 |
Module: Postoffice Skel, Service: postoffice_skel.message_subscriber Class: \Drupal\postoffice_skel\EventSubscriber\MessageSubscriber Wraps a message into a HTML document skeleton. |
-125 |
Module: Postoffice Inline Styles, Service: postoffice_inline_styles.message_subscriber Class: \Drupal\postoffice_inline_styles\EventSubscriber\MessageSubscriber Inlines CSS from libraries attached during the rendering of a message. |
-150 |
Module: Postoffice, Service: postoffice.default_address_subscriber Class: \Drupal\postoffice\EventSubscriber\DefaultAddressSubscriber Sets the sender , from and to address to the site default if one of them is still empty. |
-200 |
Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion