Reputation: 21
I want to send a MIME Message to Mailgun using the old SMTP API (not the REST API) inside an old Laravel 6 Project. I know that you can set the template variables to use by adding the 'X-Mailgun-Template-Variables' header to the MIME Message but i cannot find a way to set the template name (the name inside the Mailgun dashboard template section) to use.
At the moment i tried setting the name:
I also cannot find documentation on this subject in the Mailgun documentation or anywhere else on the web. Because of the way the project is organised, switching to the Mailgun SDK for mail delivery is not that easy.
Upvotes: 1
Views: 800
Reputation: 21
I found the solution myself, so hopefully it will help other people that have the same Problem.
You can set the template name to use by using the X-Mailgun-Template-Name
header and setting the name of your template as the value.
The template variables / placeholders you can set as a json string using the X-Mailgun-Template-Variables
header.
For example if you use PHP SwiftMailer you can do the following:
$message->getHeaders()->addTextHeader('X-Mailgun-Template-Name', 'mytemplate');
$message->getHeaders()->addTextHeader('X-Mailgun-Template-Variables', \json_encode(['foo' => 'bar']));
Hopes this helps some folks because i also could not find any documentation on the web on how to use this feature with the old smtp integration.
Upvotes: 1