{"id":18924129,"url":"https://github.com/hellsan631/nodemailer-templation","last_synced_at":"2026-03-14T00:30:28.727Z","repository":{"id":35275585,"uuid":"39536378","full_name":"hellsan631/nodemailer-templation","owner":"hellsan631","description":"Nodemailer wrapper for easily sending HTML templated emails","archived":false,"fork":false,"pushed_at":"2015-09-02T02:17:10.000Z","size":152,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T08:19:01.343Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://humanexploit.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellsan631.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-23T00:07:33.000Z","updated_at":"2021-04-28T21:30:05.000Z","dependencies_parsed_at":"2022-09-16T21:51:11.497Z","dependency_job_id":null,"html_url":"https://github.com/hellsan631/nodemailer-templation","commit_stats":null,"previous_names":["hellsan631/templation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fnodemailer-templation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fnodemailer-templation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fnodemailer-templation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fnodemailer-templation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellsan631","download_url":"https://codeload.github.com/hellsan631/nodemailer-templation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239921877,"owners_count":19718842,"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":[],"created_at":"2024-11-08T11:05:54.642Z","updated_at":"2026-03-14T00:30:28.697Z","avatar_url":"https://github.com/hellsan631.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nodemailer-templation\n_A Nodemailer wrapper for easily sending HTML templated emails._\n\nI've always had problems trying to send emails via multiple HTML templates. There really wasn't anything that solved\nall of my needs in a way that was easy and made sense to me. I found a code snippit some where for node 0.8x,\nthat didn't work, so I adapted it into this package.\n\n### Installation\n\nInstall via __Download__,\n\n__NPM (recommended)__\n```bash\nnpm install --save nodemailer-templation\n```\n\n### Useage\n\nYou need an __external SMTP server__ or service to make this work. I recommend Mandrill. Its free, and fast.\n\nExample using [mandrill](mandrillapp.com) as our SMTP service.\n```js\nvar Templation  = require('nodemailer-templation');\nvar path        = require('path');\n\n//Create our new new mailer object\nvar Mailer = new Templation({\n    from: 'hello@example.com',\n    templates: {\n      reply: path.resolve(__dirname, '../templates/reply.html')\n    },\n    attachments: [\n      {\n        filename: 'logoLite.png',\n        path: path.resolve(__dirname, '../templates/images/logoLite.png'),\n        cid: 'light@logo'\n      },\n      {\n        filename: 'logoDark.png',\n        path: path.resolve(__dirname, '../templates/images/logoDark.png'),\n        cid: 'dark@logo'\n      }\n    ],\n    transportOptions: {\n      host: 'smtp.mandrillapp.com',\n      port: 587,\n      auth: {\n        user: 'SomeUserName',\n        pass: 'SomeUserNameAPIKEY'\n      }\n    }\n  });\n\n//Send a mail using a template you've created, and listed under the templates option above.\nMailer.send({\n  to: 'acoolguy@google.com',\n  subject: 'Hello World',\n  template: 'reply',\n  messageData: {\n    title: 'Hello Dude',\n    name: 'Woah',\n    message: 'Far Out'\n  }\n});\n\n//Send a mail using the default template\nMailer.send({\n  to: 'a2coolguy@google.com',\n  subject: 'Hello World',\n  messageData: {\n    title: 'Hello Dude',\n    name: 'Woah',\n    message: 'Far Out',\n    copymark: '(c) TooCool LLC 1995'\n  }\n});\n```\n\n### Templation Options\n\nThere are the options you can send in when you create your new Templation object.\u003cbr/\u003e\n\n__attachments__ _(array) of objects_\n```js\nvar attachments = [\n  {\n    filename: 'logoLite.png',\n    path: path.resolve(__dirname, '../templates/images/logoLite.png'),\n    cid: 'light@logo' //used in your template when you send emails.\n  }\n];\n\n/* Example including above logo attachment\n\u003cimg src=\"cid:light@logo\" alt=\"My Company LLC.\"\u003e\n*/\n```\n\u003cbr/\u003e\n__templates__ _list of objects_\n```js\nvar templates = {\n  //name: \"path\"\n  reply: path.resolve(__dirname, '../templates/reply.html'),\n  answer: path.resolve(__dirname, '../templates/answer.html'),\n  news-letter: path.resolve(__dirname, '../templates/news-letter.html')\n};\n```\n\u003cbr/\u003e\n__defaultTemplate__ _string_ \u003cbr/\u003e\nThe default template used when you don't send in a template string for the mailer options.\n```js\nvar defaultTemplate = path.resolve(__dirname, '../templates/default.html');\n```\n\u003cbr/\u003e\n__templateOptions__ _object_ \u003cbr/\u003e\n[Lodash template options](https://lodash.com/docs#template).\n```js\nvar templateOptions = {\n  interpolate: /{{([\\s\\S]+?)}}/g //use {{thing}} as a basis for dynamic message data\n};\n```\n\u003cbr/\u003e\n__generateTextFromHTML__ _boolean_ \u003cbr/\u003e\nTo generate text from HTML or neigh.\n\u003cbr/\u003e\u003cbr/\u003e\n\n__transportOptions__ _object (required)_ \u003cbr/\u003e\n[nodemailer-smtp-transport options](https://github.com/andris9/nodemailer-smtp-transport#usage).\nYou can either set this to be used for all templates, or send in a transportOptions field when you\nuse the send() method below.\n```js\nvar transportOptions = {\n  host: 'smtp.mandrillapp.com',\n  port: 587,\n  auth: {\n    user: 'SomeUserName',\n    pass: 'SomeUserNameAPIKEY'\n  }\n};\n```\n\u003cbr/\u003e\n__from__ _string (required)_ \u003cbr/\u003e\nThe email address of where you are sending this from. You can either set this to be used for all templates,\nor send in a from field when you use the send() method below.\n```js\nvar from = \"some@email.com\";\n```\n\n### Templation.send() Method Options\n\nThese are the options when you send using your Template object\n```js\nvar Mailer = new Templation(templationOptions);\nMailer.send(mailerOptions);\n```\n\u003cbr/\u003e\n\n__to__ _object or string (required)_\n```js\nvar to = { //equivalent to \"Bruce Wayne \u003ciamnotbatman@wayne.com\u003e\"\n  name: 'Bruce Wayne',\n  email: 'iamnotbatman@wayne.com'\n};\n\n//OR\n\nvar to = \"iamnotbatman@wayne.com\";\n```\n\u003cbr/\u003e\n\n__from__ _string (see above)_ \u003cbr/\u003e\n\u003cbr/\u003e\n\n__subject__ _string (required)_\n```js\nvar subject = 'TPS Reports';\n```\n\u003cbr/\u003e\n\n__template__ _string_ \u003cbr/\u003e\nThe name of the template if you defined one above, or a (string) path to a template.html file\n```js\nvar template = 'report';\n\n//OR\n\nvar template = path.resolve(__dirname, '/someTemplate.html');\n```\n\u003cbr/\u003e\n\n__messageData__ _object_ \u003cbr/\u003e\nCorresponding fields to what is inside of the template.html file\n```js\nvar messageData = {\n  title: 'Hello Dude',\n  name: 'Woah',\n  message: 'Far Out',\n  copymark: '(c) TooCool LLC 1995'\n};\n```\n\u003cbr/\u003e\n\n__transportOptions__ _object (see above)_\u003cbr/\u003e\n\u003cbr/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellsan631%2Fnodemailer-templation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellsan631%2Fnodemailer-templation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellsan631%2Fnodemailer-templation/lists"}