In my project where I use Mailgun to send emails, I want to tag emails as described here. But I can't find how to do that with symfony/mailer and symfony/mailgun-mailer provider and can't find any documentation about that, can anyone help me with this?
I find the solution and want to share it with other developers. I add "X-Mailgun-Tag"
header and it works.
$message = (new TemplatedEmail())
->from(new NamedAddress($senderEmail, $senderName))
->to(new NamedAddress($receiverEmail, $receiverName))
->subject($subject)
->htmlTemplate($template)
->context($context);
$message->getHeaders()->addTextHeader('X-Mailgun-Tag', $tag1);
$message->getHeaders()->addTextHeader('X-Mailgun-Tag', $tag2);