Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Symfony Mailer & SendGrid custom arguments #42481

Unanswered
abzolv asked this question in Q&A
Aug 11, 2021 · 3 comments · 2 replies
Discussion options

SendGrid has a feature where you can send custom arguments along with an email. The custom arguments are added to the SendGrid webhook events that they send back to your endpoint.

It does not appear to be currently possible to add the custom arguments when using Symfony Mailer.

Am I missing something, or can it be added as an enhancement?

https://docs.sendgrid.com/for-developers/tracking-events/event#custom-arguments
https://github.com/sendgrid/sendgrid-php/blob/main/examples/helpers/mail/example.php#L46

You must be logged in to vote

Replies: 3 comments · 2 replies

Comment options

You should check this repository - https://github.com/symfony/sendgrid-mailer - if there is some support for those or not.

And if you don't find anything there, then create an issue to main repository - https://github.com/symfony/symfony/issues - about that.

You must be logged in to vote
0 replies
Comment options

@abzolv I don't know if it's the same, but Symfony Mailer allows to add metadata and tags to emails. See https://symfony.com/doc/current/mailer.html#adding-tags-and-metadata-to-emails

You must be logged in to vote
2 replies
@abzolv
Comment options

The issue is that the SendgridApiTransport::getPayload method of Symfony SendGrid Bridge does not contain any code to handle TagHeader and MetadataHeader instances added to the email headers in Symfony Mailer. Whereas, PostmarkApiTransport::getPayload does contain code to convert those headers into Postmark tracking format.

It must just be an oversight because SendGrid tracking has been a long-time feature of SendGrid.

@javiereguiluz
Comment options

You are right. I think it's a matter of adding to the SendGrid Bridge some code similar to this: https://github.com/symfony/mailgun-mailer/blob/afd868ec8509d9ef372d37aedc7a5ee24e7697c3/Transport/MailgunApiTransport.php#L125-L135

If you have some free time, it'd be great if you could submit a pull request with these changes for the SendGrid Bridge. These mailer bridges are maintained by the community because Symfony creators can't use and know all possible mailer services. That's why we need help from people like you who are experienced in each mailer. Thanks 🙏

Comment options

custom_args worked fine for me with this line of code:

$email->getHeaders()->add(new MetadataHeader('Color', 'blue'));

and make sure you use api transport: MAILER_DSN=sendgrid+api://KEY@default?region=REGION

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.