- Issue created by @ressa
- 🇩🇰Denmark ressa Copenhagen
Thanks for the answer. I found the Hooks → page, and managed to get it working:
<?php use Drupal\symfony_mailer\EmailInterface; /** * Implements hook_mailer_TYPE_build() for emails of type XXX. */ function my_custom_mailer_simplenews_build(EmailInterface $email) { $email->getHeaders()->addHeader("MessageStream", "broadcast"); }
I added a "Add custom headers" section to the Hooks → documentation page.
I wasn't initially sure how to find the value of "emails of type XXX" mentioned, but managed to find the
src/Plugin/EmailBuilder
folder, which had some email types. I guess forCommerceOrderEmailBuilder.php
, you would need to replaceXXX
withcommerceorder
?My task is solved now, but I do still think that adding support for custom headers would be a nice feature, especially for those users who don't have the know how to build a custom module ...
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
3 months ago 11:08am 2 June 2025 - First commit to issue fork.
- 🇫🇷France opi
If needed, I've created a merge request to add a new email policy adjuster which allows to define a custom header from the UI : https://git.drupalcode.org/project/symfony_mailer/-/merge_requests/168
The merge request is against the 2.x branch, if anyone need this for 1.6.x here is the corresponding gist : https://gist.github.com/opi/a5a6d2cee2c2166709421d6f9a85aaeb
- 🇩🇰Denmark ressa Copenhagen
Fantastic news @opi! This issue might be closed for good, and hard or not possible to reopen, so I created a new issue ✨ Add support for custom headers Active . Perhaps you can add the MR there? Thanks!