{"id":19408507,"url":"https://github.com/4lessandrodev/ts-mailer","last_synced_at":"2025-04-24T09:31:54.851Z","repository":{"id":41330303,"uuid":"471588274","full_name":"4lessandrodev/ts-mailer","owner":"4lessandrodev","description":"A lib to send email using hbs template and aws ses","archived":false,"fork":false,"pushed_at":"2025-04-07T03:05:18.000Z","size":2561,"stargazers_count":7,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T21:17:12.449Z","etag":null,"topics":["aws-ses","hbs-template-mail","mailer","mailer-service","template-email-sender"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ts-mailer","language":"TypeScript","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/4lessandrodev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-19T04:07:42.000Z","updated_at":"2025-04-01T02:07:01.000Z","dependencies_parsed_at":"2023-10-02T04:44:45.661Z","dependency_job_id":"c25e82dd-a00e-4dcf-af93-9c4f964ea73f","html_url":"https://github.com/4lessandrodev/ts-mailer","commit_stats":{"total_commits":84,"total_committers":3,"mean_commits":28.0,"dds":"0.29761904761904767","last_synced_commit":"d4b20f9685bc7c3b1725ef4200d00e72be371af3"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lessandrodev%2Fts-mailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lessandrodev%2Fts-mailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lessandrodev%2Fts-mailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lessandrodev%2Fts-mailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4lessandrodev","download_url":"https://codeload.github.com/4lessandrodev/ts-mailer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250600718,"owners_count":21457017,"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":["aws-ses","hbs-template-mail","mailer","mailer-service","template-email-sender"],"created_at":"2024-11-10T12:06:24.167Z","updated_at":"2025-04-24T09:31:54.449Z","avatar_url":"https://github.com/4lessandrodev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-mailer\n\nThis lib provide a class and function as singleton instance to compile a hbs template adding data and send it as an email using aws-ses.\n## Send email using hbs template and aws-ses\n\n\u003ca href=\"https://www.npmjs.com/package/ts-mailer\" rel=\"nofollow\" class=\"keychainify-checked\"\u003e\n \u003cimg src=\"https://badgen.net/github/checks/4lessandrodev/ts-mailer/main\" \n alt=\"checks\" \n style=\"max-width: 100%;\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/ts-mailer\" rel=\"nofollow\" class=\"keychainify-checked\"\u003e\n \u003cimg src=\"https://badgen.net/github/stars/4lessandrodev/ts-mailer\" \n alt=\"stars\" \n style=\"max-width: 100%;\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/ts-mailer\" rel=\"nofollow\" class=\"keychainify-checked\"\u003e\n \u003cimg src=\"https://badgen.net/github/commits/4lessandrodev/ts-mailer/main\" \n alt=\"commits\" \n style=\"max-width: 100%;\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/ts-mailer\" rel=\"nofollow\" class=\"keychainify-checked\"\u003e\n \u003cimg src=\"https://badgen.net/github/last-commit/4lessandrodev/ts-mailer/main\" \n alt=\"last commit\" \n style=\"max-width: 100%;\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/ts-mailer\" rel=\"nofollow\" class=\"keychainify-checked\"\u003e\n \u003cimg src=\"https://badgen.net/github/license/4lessandrodev/ts-mailer\" \n alt=\"license\" \n style=\"max-width: 100%;\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/ts-mailer\" rel=\"nofollow\" class=\"keychainify-checked\"\u003e\n \u003cimg src=\"https://badgen.net/github/dependabot/4lessandrodev/ts-mailer\" \n alt=\"dependabot\" \n style=\"max-width: 100%;\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/ts-mailer\" rel=\"nofollow\" class=\"keychainify-checked\"\u003e\n \u003cimg src=\"https://badgen.net/github/tag/4lessandrodev/ts-mailer\" \n alt=\"tags\" \n style=\"max-width: 100%;\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/ts-mailer\" rel=\"nofollow\" class=\"keychainify-checked\"\u003e\n \u003cimg src=\"https://badgen.net/github/closed-issues/4lessandrodev/ts-mailer\" \n alt=\"issues\" \n style=\"max-width: 100%;\"\u003e\n\u003c/a\u003e\n\n### Remember to configure your aws-ses\n\nAccess you aws account and set your [aws-ses](https://aws.amazon.com/ses/?nc2=type_a)\n\nTutorial step by step [Here](https://www.replyup.com/blog/amazon-ses-tutorial/)\n\n### Installation\n\n```sh\n\n$ npm install ts-mailer\n\n# OR \n\n$ yarn add ts-mailer\n\n```\n\n### Variables on your .env\n\n```env\n\nAWS_ACCESS_KEY_ID=\nAWS_SECRET_ACCESS_KEY=\nAWS_MAILER_REGION=\n\n```\n\n### Create your hbs template \n\nYou can define attributes using double key as example below. [Documentation](https://handlebarsjs.com/guide/)\n\nYou can preview your template using vscode extension [Here](https://marketplace.visualstudio.com/items?itemName=greenbyte.handlebars-preview)\n\n```html\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\u003emy-template\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003c!-- data will apply this attribute ---\u003e\n    \u003ch1\u003e{{ userName }}\u003c/h1\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\n\n```\n\n### Import lib\n\nThe lib provide a singleton instance fo all your application as function or class\n\nExample how to import it as Class\n\n```ts\n\nimport { SESMailer } from 'ts-mailer';\n\nconst sesMailer = new SESMailer();\n\nconst result = await sesMailer.sendEmail({ ... });\n\n```\n\nExample how to import it as function\n\n```ts\n\nimport { mailer } from 'ts-mailer';\n\n```\n\n### Sending an email\n\nThe mailer imported already is a singleton instance. you do not need to instantiate it.\n\n```ts\n\nimport { resolve } from 'path';\n\nconst result = await mailer.sendEmail({\n\tfromEmail: 'my-email@domain.com',\n\tsubject: 'some subject',\n\ttemplatePath: resolve(__dirname, 'templates', 'my-template.hbs'),\n\ttoEmails: ['destination@domain.com'],\n\tdata: { userName: 'John Doe' },\n\tbcc: ['financial@domain.com'],\n\tcc: ['my-email@domain.com']\n});\n\n```\n\n### Payload\n\n```ts\n\nconsole.log(result);\n\n`\n\"$metadata\": {\n  \"httpStatusCode\": 200,\n  \"requestId\": \"e6c808b4-4246-43a5-908d-bfb2d42b5de0\",\n  \"attempts\": 1,\n  \"totalRetryDelay\": 0\n}\n\"MessageId\": \"0100017fa29f0e77-d32250df-e245-4bbc-b7f3-9d56a0a214ae-000000\"\n`\n```\n### Summary\n\n- `fromEmail`: email address origin (email you set on your aws-ses)\n- `subject`: email subject\n- `templatePath`: the dir path to get your hbs template\n- `toEmails`: emails recipients\n- `data`: attributes value to handled and apply on your hbs template\n- `bcc`: emails recipients to receive as blind carbon copy\n- `cc`: emails recipients to send a visible copy\n\n### Generic Types \n\nYou can define interfaces to your template data. Generic types.\n\n```ts\n\ninterface TemplateData {\n\tuserName: string\n\turl: string\n}\n\n```\n\nSo you can provide your interface on call `sendEmail` function.\nNow the data attributes will be typed\n\n```ts\n\nawait mailer.sendEmail\u003cTemplateData\u003e({ ...params, data: { url, userName } });\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4lessandrodev%2Fts-mailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4lessandrodev%2Fts-mailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4lessandrodev%2Fts-mailer/lists"}