Skip to content

Commit d435798

Browse files
committed
[Mailer] Documented the tag and metadata headers
1 parent 705e761 commit d435798

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

mailer.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,39 @@ Alternatively, you can pass multiple addresses to each method::
183183
// ...
184184
;
185185

186+
Message Headers
187+
~~~~~~~~~~~~~~~
188+
189+
Messages include a number of header fields to describe their contents. Symfony
190+
sets all the required headers automatically, but you can set your own headers
191+
too. There are different types of headers (Id header, Mailbox header, Date
192+
header, etc.) but most of the times you'll set text headers::
193+
194+
$email = (new Email())
195+
->getHeaders()
196+
// this header tells auto-repliers ("email holiday mode") to not
197+
// reply to this message because it's an automated email
198+
->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply');
199+
200+
// ...
201+
;
202+
203+
When using a mailer service that supports tags and metadata, consider using the
204+
``TagHeader`` and ``MetadataHeader`` headers instead of the plain text headers::
205+
206+
use Symfony\Component\Mailer\Header\MetadataHeader;
207+
use Symfony\Component\Mailer\Header\TagHeader;
208+
209+
$email->getHeaders()->add(new TagHeader('password-reset'));
210+
$email->getHeaders()->add(new MetadataHeader('Client-ID', '12345'));
211+
212+
If your mailer doesn't support these tag/metadata headers, they are added to the
213+
message as text headers (``X-Tag: password-reset``, ``X-Metadata-Client-ID: 12345``).
214+
215+
.. versionadded:: 5.1
216+
217+
The ``TagHeader`` and ``MetadataHeader`` headers were introduced in Symfony 5.1.
218+
186219
Message Contents
187220
~~~~~~~~~~~~~~~~
188221

0 commit comments

Comments
 (0)