简体   繁体   English

邮戳:发送带有模板的电子邮件

[英]Postmark: Send email with template

I am trying to send a template email with Postmark in Node.js我正在尝试在 Node.js 中发送带有 Postmark 的模板电子邮件

I created a template on the Postmark App website.我在 Postmark App 网站上创建了一个模板。 I've looked through their documentation, but cannot find any way to go about sending a templated email.我查看了他们的文档,但找不到任何发送模板电子邮件的方法。

Documentation Sources:文档来源:

http://blog.postmarkapp.com/post/125849089273/special-delivery-postmark-templates http://developer.postmarkapp.com/developer-api-templates.html http://blog.postmarkapp.com/post/125849089273/special-delivery-postmark-templates http://developer.postmarkapp.com/developer-api-templates.html

I've tried a variety of methods, including:我尝试了多种方法,包括:

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'类型错误:对象 # 没有方法“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 }控制台日志错误:{ 状态:422,消息:'A \\'TemplateId\\' 在发送非模板化电子邮件时不得使用。',代码:1123 }

Thanks!谢谢!

I'm the current maintainer of the node.js library (as well as one of the engineers that worked on Postmark Templates).我是 node.js 库的当前维护者(也是从事 Postmark Templates 的工程师之一)。

One of the possible reasons the original snippet doesn't work is that you could be using an older version of Postmark.js.原始代码段不起作用的可能原因之一是您可能使用的是较旧版本的 Postmark.js。 We added the template endpoint capabilities in version 1.2.1 of the node.js package.我们在 node.js 包的 1.2.1 版中添加了模板端点功能。

In the package.json file for your project you should make sure to update it to use version 1.2.1 or greater of the postmark.js library.在项目的 package.json 文件中,您应该确保将其更新为使用 1.2.1 或更高版本的 postmark.js 库。 If you've been using an older version of the library, you'll also need to run npm update如果你一直在使用旧版本的库,你还需要运行npm update

Also note that if you click "Edit Template" in the Postmark UI, and then "API Snippets," the UI provides a completed snippet for a number of languages (including node.js).另请注意,如果您在 Postmark UI 中单击“编辑模板”,然后单击“API Snippets”,则 UI 会为多种语言(包括 node.js)提供完整的代码段。

If all else fails, please contact support and we'll be happy to help you solve this issue.如果所有其他方法都失败,请联系支持人员,我们将很乐意帮助您解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM