【发布时间】:2020-06-03 21:39:52
【问题描述】:
我制作了一个谷歌云功能,我在其中发送一封电子邮件,其中包含我从另一个地方收到的一些变量。 我正在使用 mailgun.js 并尝试使用已在 mailgun 中创建的模板发送电子邮件。 问题是我找不到替换模板中占位符变量的方法。
这是代码:
mg.messages.create('domain', {
from: 'email',
to: [email],
subject: 'subject',
template: 'template',
// How to replace the template variables???
})
.then(res => console.log('Resolved >>>>> ', res))
.catch(err => console.log('MAILGUN ERROR >>>> ', err))
mailgun docs 是这样说的:
var data = {
from: 'Excited User <me@samples.mailgun.org>',
to: 'alice@example.com',
subject: 'Hello',
template: 'template.test',
h:X-Mailgun-Variables: '{"title": "API Documentation", "body": "Sending messages with templates"}' // Notice this
};
据我所知,不能将“h:X-Mailgun-Variables”写为任何对象的键。
有人知道我需要把它放在哪里或如何放置吗?
我认为它应该作为标头发送,但 mailgun/mailgun-js 和 highlycaffeinated/mailgun-js 都没有指定如何传递标头。
【问题讨论】:
-
您可以发布您的模板内容吗?您是否存储了您的模板?
标签: javascript node.js mailgun