zeptomail
v6.1.0
Published
Send mail via Node.js with ZeptoMail
Downloads
11,837
Readme
Send mail via Node
🛠️ Installation
To install the ZeptoMail, you first need to Sign Up to ZOHO.
Then you need to install Node.js and npm.
Installing zeptomail
is simple and easy. Start by entering the following command in your system terminal:
npm install zeptomail
📊 Obtain an API Key
Grab your API Key from the Zeptomail
📒 Example
Example for email sending (sendMail), sending single email using tempalte (sendMailWithTemplate) and sending batch emails using template (mailBatchWithTemplate) are available below.
Send mail
// For ES6, set type: "module" in package.json.
import { SendMailClient } from "zeptomail";
// For CommonJS
var { SendMailClient } = require("zeptomail");
const url = "api.zeptomail.com/";
const token = "<Send mail token>";
let client = new SendMailClient({url, token});
client.sendMail({
"from":
{
"address": "[email protected]",
"name": "test"
},
"to":
[
{
"email_address":
{
"address": "[email protected]",
"name": "test1"
}
}
],
"reply_to":
[
{
"address": "[email protected]",
"name": "test2"
}
],
"subject": "Sending with ZeptoMail to have good experience",
"textbody": "Easy to do from anywhere, with Node.js",
"htmlbody": "<strong>Easy to do from anywhere, with Node.js</strong>",
"cc":
[
{
"email_address":
{
"address": "[email protected]",
"name": "test3"
}
}
],
"bcc":
[
{
"email_address":
{
"address": "[email protected]",
"name": "test4"
}
}
],
"track_clicks": true,
"track_opens": true,
"client_reference": "<client reference>",
"mime_headers":
{
"X-Zylker-User": "test-xxxx"
},
"attachments":
[
{
"content": "..x+SEXa3zKfnDnBA2qExtXikBpUAFABQAhGSPY/0IoAWgD/2Q==",
"mime_type": "image/jpg",
"name": "DM-welcome-guide"
},
{
"file_cache_key": "<File Cache Key>",
"name": "DM-reports"
}
],
"inline_images":
[
{
"mime_type": "image/jpg",
"content": "...x+SEXa3zKfnDnBA2qExtXikBpUAFABQAhGSPY/0IoAWgD/2Q==",
"cid": "img-welcome-design"
},
{
"file_cache_key": "<File Cache Key>",
"cid": "img-CTA"
}
]
}).then((resp) => console.log("success")).catch((error) => console.log("error"));
Send batch mail
// For ES6, set type: "module" in package.json.
import { SendMailClient } from "zeptomail";
// For CommonJS
var { SendMailClient } = require("zeptomail");
const url = "api.zeptomail.com/";
const token = "<Send mail token>";
client.sendBatchMail({
"from": {
"address": "[email protected]",
"name": "test"
},
"to": [
{
"email_address": {
"address": "[email protected]",
"name": "test1"
},
"merge_info": {
"name": "Micheal scott"
}
}
],
"reply_to":
[
{
"address": "[email protected]",
"name": "test2"
}
],
"subject": "Sending with ZeptoMail to have good experience",
"textbody": "Hi {{name}}, sending email is easy to do from anywhere, with Node.js",
"htmlbody": "Hi {{name}},<br /><strong> Sending email is easy to do from anywhere, with Node.js</strong>",
"cc":
[
{
"email_address":
{
"address": "[email protected]",
"name": "test3"
}
}
],
"bcc":
[
{
"email_address":
{
"address": "[email protected]",
"name": "test4"
}
}
],
"track_clicks": true,
"track_opens": true,
"client_reference": "<client reference>",
"mime_headers":
{
"X-Zylker-User": "test-xxxx"
},
"attachments":
[
{
"content": "..x+SEXa3zKfnDnBA2qExtXikBpUAFABQAhGSPY/0IoAWgD/2Q==",
"mime_type": "image/jpg",
"name": "DM-welcome-guide"
},
{
"file_cache_key": "<File Cache Key>",
"name": "DM-reports"
}
],
"inline_images":
[
{
"mime_type": "image/jpg",
"content": "...x+SEXa3zKfnDnBA2qExtXikBpUAFABQAhGSPY/0IoAWgD/2Q==",
"cid": "img-welcome-design"
},
{
"file_cache_key": "<File Cache Key>",
"cid": "img-CTA"
}
]
}).then((resp) => console.log("success")).catch((error) => console.log("error"));
Send template mail
// For ES6, set type: "module" in package.json.
import { SendMailClient } from "zeptomail";
// For CommonJS
var { SendMailClient } = require("zeptomail");
const url = "api.zeptomail.com/";
const token = "<Send mail token>";
client.sendMailWithTemplate({
"template_key": "<template key>",
"template_alias": "<template's alias>",
"from": {
"address": "[email protected]",
"name": "test"
},
"to": [
{
"email_address": {
"address": "[email protected]",
"name": "test1"
}
}
],
"cc": [
{
"email_address": {
"address": "[email protected]",
"name": "test3"
}
}
],
"bcc": [
{
"email_address": {
"address": "[email protected]",
"name": "test5"
}
}
],
"merge_info": {
"contact_number": "8787xxxxxx789",
"company": "example.com"
},
"reply_to": [
{
"address": "[email protected]",
"name": "test7"
}
],
"client_reference": "<client reference>",
"mime_headers": {
"X-Test": "test"
}
}).then((resp) => console.log("success")).catch((error) => console.log("error"));
Send batch template mail
// For ES6, set type: "module" in package.json.
import { SendMailClient } from "zeptomail";
// For CommonJS
var { SendMailClient } = require("zeptomail");
const url = "api.zeptomail.com/";
const token = "<Send mail token>";
client.mailBatchWithTemplate({
"template_key": "<template's key>",
"template_alias": "<template's alias>",
"from": {
"address": "[email protected]",
"name": "test"
},
"to": [
{
"email_address": {
"address": "[email protected]",
"name": "test1"
},
"merge_info": {
"contact_number": "8787xxxxxx789",
"company": "example.com"
}
}
],
"reply_to": [
{
"address": "[email protected]",
"name": "test"
}
],
"client_reference": "<client reference>",
"mime_headers": {
"X-Test": "test"
}
}).then((resp) => console.log("success")).catch((error) => console.log("error"));
📒 Contact Us
Contact us at [email protected]
for any questions regarding Zoho ZeptoMail.