@@ -730,6 +730,47 @@ adding a text header ``X-Transport`` to an email::
730
730
$email->getHeaders()->addTextHeader('X-Transport', 'important');
731
731
$mailer->send($email);
732
732
733
+ Adding Tags and Metadata to Emails
734
+ ----------------------------------
735
+
736
+ Certain 3rd party transports support email *tags * and *metadata *. These can be
737
+ used by the 3rd party service for grouping, tracking and workflows. The
738
+ :class: `Symfony\\ Component\\ Mailer\\ Header\\ TagHeader ` and
739
+ :class: `Symfony\\ Component\\ Mailer\\ Header\\ MetadataHeader ` headers can be
740
+ added to your email. If your transport supports these headers, they will be
741
+ applied in the format specific to the transport.
742
+
743
+ .. versionadded :: 5.1
744
+
745
+ The :class: `Symfony\\ Component\\ Mailer\\ Header\\ TagHeader ` and
746
+ :class: `Symfony\\ Component\\ Mailer\\ Header\\ MetadataHeader ` classes were
747
+ introduced in Symfony 5.1.
748
+
749
+ The following 3rd party transports currently support tags and metadata:
750
+
751
+ * Postmark
752
+ * Mailgun
753
+ * MailChimp
754
+
755
+ For example, say you want to tag an email and add some metadata::
756
+
757
+ use Symfony\Component\Mailer\Header\MetadataHeader;
758
+ use Symfony\Component\Mailer\Header\TagHeader;
759
+
760
+ $email->getHeaders()->add(new TagHeader('password-reset'));
761
+ $email->getHeaders()->add(new MetadataHeader('Color', 'blue'));
762
+ $email->getHeaders()->add(new MetadataHeader('Client-ID', '12345'));
763
+
764
+ When sending this email with a transport that supports tags and metadata, the transport
765
+ will convert these to their appropriate format. If using a transport that does not
766
+ support tags and metadata, they will be added as custom headers:
767
+
768
+ .. code-block :: text
769
+
770
+ X-Tag: password-reset
771
+ X-Metadata-Color: blue
772
+ X-Metadata-Client-ID: 12345
773
+
733
774
Development & Debugging
734
775
-----------------------
735
776
0 commit comments