我正在尝试在 Node.js 中发送带有邮戳的模板电子邮件
我在 Postmark App 网站上创建了一个模板。我查看了他们的文档,但找不到发送模板化电子邮件的任何方法。
文档来源:
http://blog.postmarkapp.com/post/125849089273/special-delivery-postmark-templates http://developer.postmarkapp.com/developer-api-templates.html
我尝试了多种方法,包括:
client.emailWithTemplate("jenny@example.com",
"bob@example.com",<template-id>, {
"link" : "https://example.com/reset?key=secret",
"recipient_name" : "Jenny"
});
TypeError: Object # has no method 'emailWithTemplate'
client.sendEmail({
"TemplateModel" : {
"customer_name" : "Jenny",
},
"TemplateId" : 6882,
"From": "info@formulastocks.com",
"To": "lrroberts0122@gmail.com",
}, function(error, success) {
if(error) {
console.log(error);
} else {
console.log(success);
}
});
Console Log Error: { status: 422, message: 'A \'TemplateId\' must not be used when sending a non-templated email.', code: 1123 }
谢谢!
最佳答案
我是 node.js 库的当前维护者(也是从事 Postmark 模板的工程师之一)。
原始代码段不起作用的可能原因之一是您使用的可能是旧版本的 Postmark.js。我们在 node.js 包的 1.2.1 版中添加了模板端点功能。
在项目的 package.json 文件中,您应该确保将其更新为使用 1.2.1 或更高版本的 postmark.js 库。如果您一直在使用旧版本的库,您还需要运行 npm update
另请注意,如果您在 Postmark UI 中单击“编辑模板”,然后单击“API 片段”,则该 UI 会提供多种语言(包括 node.js)的完整片段。
如果一切都失败了,请联系支持人员,我们很乐意帮助您解决此问题。
关于node.js - 邮戳:发送带有模板的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32081626/