{"id":23978054,"url":"https://github.com/shiv-source/node-multi-mailer","last_synced_at":"2025-02-24T18:52:28.260Z","repository":{"id":47627421,"uuid":"396093466","full_name":"shiv-source/node-multi-mailer","owner":"shiv-source","description":"A simple node.js module that exposes high-level API of Nodemailer and SendGrid.","archived":false,"fork":false,"pushed_at":"2021-08-23T15:14:43.000Z","size":85,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-07T08:16:10.807Z","etag":null,"topics":["ejs","ejs-templates","email","emailtemplate","express","html","multimailer","node-multi-mailer","nodemailer","sendgrid"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/node-multi-mailer","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shiv-source.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-14T18:25:14.000Z","updated_at":"2021-08-20T21:59:06.000Z","dependencies_parsed_at":"2022-07-22T12:32:29.609Z","dependency_job_id":null,"html_url":"https://github.com/shiv-source/node-multi-mailer","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiv-source%2Fnode-multi-mailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiv-source%2Fnode-multi-mailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiv-source%2Fnode-multi-mailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiv-source%2Fnode-multi-mailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shiv-source","download_url":"https://codeload.github.com/shiv-source/node-multi-mailer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240540554,"owners_count":19817791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ejs","ejs-templates","email","emailtemplate","express","html","multimailer","node-multi-mailer","nodemailer","sendgrid"],"created_at":"2025-01-07T08:16:14.196Z","updated_at":"2025-02-24T18:52:28.235Z","avatar_url":"https://github.com/shiv-source.png","language":"JavaScript","readme":"# node-multi-mailer\n\n![NPM Version](https://img.shields.io/npm/v/node-multi-mailer.svg?style=flat)\n![NPM Downloads](https://img.shields.io/npm/dm/node-multi-mailer.svg)\n![GitHub release](https://img.shields.io/github/release/shiv-source/node-multi-mailer)\n![License](https://img.shields.io/github/license/shiv-source/node-multi-mailer)\n\nA simple node.js module that exposes high-level API of [Nodemailer](https://www.npmjs.com/package/nodemailer) and [SendGrid](https://www.npmjs.com/package/@sendgrid/mail).\n\n# Installation\n\n## Prerequisites\n\n- Node.js \u003e= 10.0.0\n- A [Twilio SendGrid account](https://sendgrid.com/free?source=sendgrid-nodejs) for sending emails.\n\n## Install Package\n\nThe following recommended installation requires [npm](https://npmjs.org/). If you are unfamiliar with npm, see the [npm docs](https://npmjs.org/doc/). Npm comes installed with Node.js since node version 0.8.x, therefore, you likely already have it.\n\n```sh\n\n# With NPM\n\nnpm install --save node-multi-mailer\n\n# With Yarn\n\nyarn add node-multi-mailer\n\n```\n\n### Verify Sender Identity from SendGrid\n\nVerify an email address or domain in the [Sender Authentication tab](https://app.sendgrid.com/settings/sender_auth/senders). Without this, you will receive a `403 Forbidden` response when trying to send mail.\n\n# Examples\n\nIf you want to use an email template, then add an `email` folder in your project root directory and create a `login.ejs` file in the `email` folder. You can use any template name you want.\n\nAdd `attachment` folder in your root directory for sending an email with attachments.\n\n```\nFolder structure with mail template:\n\n    +-- email\n    |   +-- login.ejs\n    +-- attachments\n    |   +-- myImage.png\n    |   +-- resume.pdf\n    |   +-- resume.docx\n    +-- node_modules\n    +-- index.js\n    +-- package.json\n```\n\nIf required, use this `login.ejs` file as an example template.\n\n```html\n\u003c!-- login.ejs --\u003e\n\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\n    \u003ctitle\u003eNode-Multi-Mailer\u003c/title\u003e\n  \u003c/head\u003e\n\n  \u003cbody\u003e\n    \u003ch1\u003eHey \u003c%= firstName %\u003e \u003c%= lastName %\u003e, Your OTP is \u003c%= otp %\u003e\u003c/h1\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Implementation with NodeJs and SendGrid\n\n```js\n// Available options inside configuration object\n\nconst multiMailer = require(\"node-multi-mailer\");\n\nconst multiMailer = multiMailer.configuration({\n  senderEmail: \"you@example.com\",\n  senderName: \"your business name\", // Business Name\n  sendGridApiKey: SENDGRID_API_KEY, // SendGrid API Key\n  replyTo: \"me@example.com\", // optional parameter [ default = senderEmail ]\n  templateFolderPath: emailFolder, // optional parameter  [ required for sending templates ]\n  attachmentFolderPath: attachmentFolder, // Optional parameter  [ required for sending attachments]\n});\n```\n\n### A normal plain text email without any attachments\n\n```js\n// index.js\n\nvar multiMailer = require(\"node-multi-mailer\");\n\n// Create a new instance of MultiMailer\nmultiMailer.configuration({\n  senderEmail: \"you@example.com\",\n  senderName: \"your business name\", // Business Name\n  sendGridApiKey: SENDGRID_API_KEY, // SendGrid API Key\n  replyTo: \"me@example.com\", // optional parameter [ default = senderEmail ]\n});\n\nvar RECEIVER_EMAIL = \"developer.shiv2020@gmail.com\";\n\n// To send a plain text email\nmultiMailer.SendGrid.sendTextEmail(\n  RECEIVER_EMAIL,\n  \"Sending email from node-multi-mailer\", // subject\n  \"Thanks for sending email with node-multi-mailer\" // body\n);\n```\n\n### A normal plain text email with attachments\n\n```js\n\n// index.js\n\nvar multiMailer = require(\"node-multi-mailer\");\nvar path = require(\"path\");\n\nvar attachmentFolder = path.join(__dirname, \"attachment\"); // attachment folder path\n\nlet attachments = [\"myImage.png\", \"resume.pdf\", \"resume.docx\"]; // pass list of files you want to send with multiMailer\n\n// Create a new instance of MultiMailer\nmultiMailer.configuration({\n  senderEmail: \"you@example.com\",\n  senderName: \"your business name\", // Business Name\n  sendGridApiKey: SENDGRID_API_KEY, // SendGrid API Key\n  replyTo: \"me@example.com\", // optional parameter [ default = senderEmail ]\n  templateFolderPath: emailFolder, // optional parameter  [ required for sending templates ]\n  attachmentFolderPath: attachmentFolder, // Optional parameter  [ required for sending attachments]\n});\n\nvar RECEIVER_EMAIL = \"developer.shiv2020@gmail.com\";\n\n// To send a plain text email\nmultiMailer.SendGrid.sendTextEmail(\n  RECEIVER_EMAIL,\n  \"Sending email from node-multi-mailer\", // subject\n  \"Thanks for sending email with node-multi-mailer\" // body\n  attachments,\n);\n```\n\n### A template email using EJS without attachments\n\n```js\n// index.js\n\nvar multiMailer = require(\"node-multi-mailer\");\nvar path = require(\"path\");\n\nvar emailFolder = path.join(__dirname, \"email\"); // template folder path\n\n// Create a new instance of MultiMailer\nmultiMailer.configuration({\n  senderEmail: \"test@example.com\",\n  senderName: SENDER_NAME, // Business Name\n  sendGridApiKey: SENDGRID_API_KEY, // SendGrid API Key\n  replyTo: \"test@example.com\",\n  templateFolderPath: emailFolder,\n});\n\nvar RECEIVER_EMAIL = \"developer.shiv2020@gmail.com\";\n\nvar data = {\n  fisrtName: \"Shiv\",\n  lastName: \"Kumar\",\n  otp: \"123456\",\n};\n\n// To send a template email\nmultiMailer.SendGrid.sendEjsTemplateWithData(\n  RECEIVER_EMAIL,\n  \"Sending email from node-multi-mailer\", // subject\n  \"login.ejs\", // template name\n  data // template data\n);\n```\n\n### A template email using EJS with attachments\n\n```js\n// index.js\n\nvar multiMailer = require(\"node-multi-mailer\");\nvar path = require(\"path\");\n\nvar attachmentFolder = path.join(__dirname, \"attachment\"); // attachment folder path\n\nvar emailFolder = path.join(__dirname, \"email\"); // template folder path\n\nlet attachments = [\"myImage.png\", \"resume.pdf\", \"resume.docx\"]; // pass list of files you want to send with multiMailer\n\n// Create a new instance of MultiMailer\nmultiMailer.configuration({\n  senderEmail: \"test@example.com\",\n  senderName: SENDER_NAME, // Business Name\n  sendGridApiKey: SENDGRID_API_KEY, // SendGrid API Key\n  replyTo: \"test@example.com\",\n  templateFolderPath: emailFolder,\n  attachmentFolderPath: attachmentFolder,\n});\n\nvar RECEIVER_EMAIL = \"developer.shiv2020@gmail.com\";\n\nvar data = {\n  fisrtName: \"Shiv\",\n  lastName: \"Kumar\",\n  otp: \"123456\",\n};\n\n// To send a template email\nmultiMailer.SendGrid.sendEjsTemplateWithData(\n  RECEIVER_EMAIL,\n  \"Sending email from node-multi-mailer\", // subject\n  \"login.ejs\", // template name\n  data // template data\n  attachments,\n);\n```\n\n## Implementation with ExpressJs\n\n### A template email using EJS without attachments\n\n```js\n// index.js\n\nvar express = require(\"express\");\nvar multiMailer = require(\"node-multi-mailer\");\nvar path = require(\"path\");\n\nvar attachmentFolder = path.join(__dirname, \"attachment\"); // attachment folder path\n\nvar emailFolder = path.join(__dirname, \"email\"); // template folder path\n\nlet attachments = [\"myImage.png\", \"resume.pdf\", \"resume.docx\"]; // pass list of files you want to send with multiMailer\n\n// Create a new instance of MultiMailer\nmultiMailer.configuration({\n  senderEmail: \"test@example.com\",\n  senderName: SENDER_NAME, // Business Name\n  sendGridApiKey: SENDGRID_API_KEY, // SendGrid API Key\n  replyTo: \"test@example.com\",\n  templateFolderPath: emailFolder,\n  attachmentFolderPath: attachmentFolder,\n});\n\nvar app = express();\n\napp.get(\"/\", async (req, res) =\u003e {\n\n  var RECEIVER_EMAIL = \"developer.shiv2020@gmail.com\";\n\n  var data = {\n    fisrtName: \"Shiv\",\n    lastName: \"Kumar\",\n    otp: \"123456\",\n  };\n\n  // To send a template email\n  await multiMailer.SendGrid.sendEjsTemplateWithData(\n    RECEIVER_EMAIL,\n    \"Sending email from node-multi-mailer\", // subject\n    \"login.ejs\", // template name\n    data // template data\n    attachments,\n  );\n\n  return res.send(\"Email sent\");\n});\n```\n\n# Contributors\n\n\u003ca href = \"https://github.com/shiv-source\"\u003e\n  \u003cimg \n    src = \"https://avatars.githubusercontent.com/u/56552766?v=4\" \n    width=\"100\" \n    height=\"100\"\n    style=\"border-radius: 50%; margin: 5px;\" \n  /\u003e\n\u003c/a\u003e\n\n# License\n\n[MIT](https://opensource.org/licenses/MIT)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiv-source%2Fnode-multi-mailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshiv-source%2Fnode-multi-mailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiv-source%2Fnode-multi-mailer/lists"}