Add example of usage with laravel Mailable class #82
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello everyone,
Changes
In this PR i added an example on how to use this package with laravel Mailable class especially with mailjet variables.
Context
Im using this package to send mailjet emails with MJML templates containing variables
{{var:name}}
and ive had a hard time figuring out how to pass variables to the API call without using the client directly.Explanation
I noticed that you are using symfony mailjet package, which uses the class
Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetApiTransport
, by reading the source code i found out that symfony mailjet mailer transform all headers on theSymfony\Component\Mime\Email
class to the JSON payload before sending the email.You can see: https://github.com/symfony/mailjet-mailer/blob/1387c1fa5f10f0d9fd2ef9716b47f2cadd67519a/Transport/MailjetApiTransport.php#L39
So by setting headers on the
Mailable
class, the email sending works with variables and other mailjet properties.I'm not sure if this is an actual feature of the package or more like a workaround.
Please correct me if im wrong, thanks in advance.
Best regards,
Abderraouf MAHDI.