I had an issue with trying to pass variables into a template that was in the Mailgun UI using the send() command.
Following the documentation for ts-mailgun, nothing would transfer the data across to the template when using the templateVars object in send().
After looking through the mailgun documentation, i found this example curl for sending an email.
curl -X POST https://api.mailgun.net/v3/example.com/messages
-F template="billing"
-H "X-Mailgun-Variables: {"firstName": "John",
"lastName": "Doe",
"number": "12345",
"data":"Mar 01, 2019",
"amount1": "23.00",
"amount2": "10.20",
"total": "33.20"}"
Yet i noticed in dist/ts-mailgun.js that the send body is this:
// Create message parts
var message = {
from: _this.fromTitle + " <" + _this.fromEmail + ">",
to: to,
subject: subject,
html: body,
'recipient-variables': templateVars
};
By changing recipient-variables to h:X-Mailgun-Variables I achieved the desired result and the variables passed through successfully.
I am happy to open a PR with the changes if that is suitable?
I had an issue with trying to pass variables into a template that was in the Mailgun UI using the send() command.
Following the documentation for ts-mailgun, nothing would transfer the data across to the template when using the templateVars object in send().
After looking through the mailgun documentation, i found this example curl for sending an email.
Yet i noticed in dist/ts-mailgun.js that the send body is this:
By changing
recipient-variablestoh:X-Mailgun-VariablesI achieved the desired result and the variables passed through successfully.I am happy to open a PR with the changes if that is suitable?