{"id":20937169,"url":"https://github.com/danibram/emailer-hbs","last_synced_at":"2026-04-12T08:32:27.479Z","repository":{"id":26824491,"uuid":"81731278","full_name":"danibram/emailer-hbs","owner":"danibram","description":"A super hero that helps you to have the full control of your emails in your API, powered by: Handlebars,Juice,Nodemailer and typescript.","archived":false,"fork":false,"pushed_at":"2022-12-07T09:36:47.000Z","size":231,"stargazers_count":0,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T20:14:43.258Z","etag":null,"topics":["emails","handlebars","juice","nodemailer","typescript"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/danibram.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":"2017-02-12T14:22:25.000Z","updated_at":"2020-05-15T16:55:20.000Z","dependencies_parsed_at":"2023-01-14T05:21:06.541Z","dependency_job_id":null,"html_url":"https://github.com/danibram/emailer-hbs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danibram/emailer-hbs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danibram%2Femailer-hbs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danibram%2Femailer-hbs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danibram%2Femailer-hbs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danibram%2Femailer-hbs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danibram","download_url":"https://codeload.github.com/danibram/emailer-hbs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danibram%2Femailer-hbs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31709293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T06:22:27.080Z","status":"ssl_error","status_checked_at":"2026-04-12T06:21:52.710Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["emails","handlebars","juice","nodemailer","typescript"],"created_at":"2024-11-18T22:33:28.739Z","updated_at":"2026-04-12T08:32:27.446Z","avatar_url":"https://github.com/danibram.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# emailer-hbs\n\n## What is this?\n\n`emailer-hbs` is a super hero that helps you to have the full control of your emails in your API. Its powered by:\n- HandlebarsJS\n- Juice\n- Nodemailer\n- Typescript\n\nIt takes an array of configuration and a folder with header footer or more partials and that template, it inlines css with juice, and compose the final email.\n\n## Configuration for the Mailer\n\nThe configuration is very easy:\n\n```\n{\n    overrideEmail: string|null,\n    from: string|null,\n    css: string[]\n    input: string\n    output: string\n    templates: string\n    partials: string\n    transport: any,\n    emailsDirectory: string\n}\n```\n\nThat is the explanation:\n\n- overrideEmail: If this string exists, it override the email you pass by the email you want, easy for devs to test it\n- from: general from, can be override if you, send from parameter to renderAndSend\n- css: Array of css paths you want to use in the emails\n- input: Where are your templates\n- output: Where you want to compile that templates\n- templates: Where inside the input are the templates\n- partials: Where inside the input are the partials\n- transport: Nodemailer Transport with your config ready\n- emailsDirectory: Path of your emails configuration\n\n## Emails configuration\n\nAn example of an email configuration:\n\n```\n{\n    title: string\n    template: string\n    body: string\n    data: string[]\n    dummyData: {}\n    composeData(input: Object): Object\n}\n```\n\nThat is the explanation:\n- title: Title of your email\n- template: Name of the template, inside your template folder\n- data: Array of the key you need to pass as config\n- dummyData: Dummy data for the emails, to test it\n- composeData: Function to parse the input data\n\n## How to use it\n\n```npm install emailer-hbs```\n\n```\nimport { Emailer } from 'emailer-hbs'\n\nimport config from '../config'\n\nif (config.env !== 'development' \u0026\u0026 config.mailer.overrideEmail) {\n    config.mailer.overrideEmail = null\n}\n\nexport default new Emailer(config.mailer)\n```\n\nOR\n\n```\nimport Mailer from 'emailer-hbs'\nimport config from '../config'\n\nif (config.env !== 'development' \u0026\u0026 config.mailer.overrideEmail) {\n    config.mailer.overrideEmail = null\n}\n\nlet mailer = Mailer(config.mailer)\n```\n\n## Folders\n\nThis is han example, of the folders i use, in src you have the templates and the common parts, of the emails, then when you cache the emails goes to cache folder, partials are like swig partials but for use in handlebars really easy, end the css with the juice power tranform the css in inline css.\n\n```\ntemplates\n├── cache\n│   ├── partials\n│   │   ├── base.html\n│   │   └── footer.html\n│   └── templates\n│       ├── access.html\n│       └── welcome.html\n└── src\n    ├── css\n    │   ├── ink-emails.css\n    │   ├── ink.css\n    │   └── style.css\n    ├── partials\n    │   ├── base.html\n    │   └── footer.html\n    └── templates\n        ├── access.html\n        └── welcome.html\n```\n\n```\n// Input\n// base.html\n\u003chead\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    {{ Compile __body__ }}\n\u003c/body\u003e\n\u003c/html\u003e\n\n// footer.html\n\u003cfooter\u003eemailer-hbs 2017\u003c/footer\u003e\n\n// welcome.html\n\u003ch1\u003eHi\u003c/h1\u003e\n{{\u003e footer}}\n```\n\n```\n// Output\n// welcome.html\n\u003chead\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003eHi\u003c/h1\u003e\n    \u003cfooter\u003eemailer-hbs 2017\u003c/footer\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Methods\n\nWhen you initialize the mailer then you can call this methods:\n\n- renderEmail (internal): render html with handlebars\n- sendEmail (internal): send an email\n- cacheEmails: cache emails, put css inline with juice and generate the final email\n- getconfig: get the config for that template\n- renderTemplate: render template\n- renderAndSend: render the template and send\n\n\n## Changelog\n\n- **1.0.9**: Now support for names with dots\n- ***21/11/2017*** 1.0.8: added support for export default in configurations\n- ***08/09/2017***: added global from (changes on RenderAndSend)\n- ***02/12/2017***: initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanibram%2Femailer-hbs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanibram%2Femailer-hbs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanibram%2Femailer-hbs/lists"}