I am new to node.js and not able to figure out how to reference js library postmark.js in node.js.
var POSTMARK_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
var postmark = require("postmark")(POSTMARK_KEY);
postmark.send({
"From": from,
"To": to,
"Subject": subject,
"TextBody": emailBody
}, function (err, to) {
if (err) {
console.log(err);
return;
}
console.log("Email sent to: %s", to);
});
I tried above code but not sure how to use postmark.js
Is there any easy way to have html email functionality using html templates in js?
You can use the "HtmlBody field to send html messages through postmark:
postmark.send({
"From": from,
"To": to,
"Subject": subject,
"TextBody": emailBody,
"HtmlBody": "<h1>hellow</h1>"
}, function (err, to) {
if (err) {
console.log(err);
return;
}
console.log("Email sent to: %s", to);
});