{"id":13836165,"url":"https://github.com/lependu/fastify-nodemailer","last_synced_at":"2025-07-20T19:32:42.337Z","repository":{"id":26885198,"uuid":"111668091","full_name":"lependu/fastify-nodemailer","owner":"lependu","description":"Fastify nodemailer plugin","archived":false,"fork":false,"pushed_at":"2023-03-21T00:56:52.000Z","size":132,"stargazers_count":26,"open_issues_count":7,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-18T01:47:52.406Z","etag":null,"topics":["fastify","fastifyjs-plugin","nodejs","nodemailer"],"latest_commit_sha":null,"homepage":null,"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/lependu.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-11-22T10:10:51.000Z","updated_at":"2023-11-16T14:29:23.000Z","dependencies_parsed_at":"2024-04-12T11:01:49.662Z","dependency_job_id":null,"html_url":"https://github.com/lependu/fastify-nodemailer","commit_stats":{"total_commits":86,"total_committers":7,"mean_commits":"12.285714285714286","dds":0.2558139534883721,"last_synced_commit":"35ff9a7cb76863a518377dda47a543f6173bc92b"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/lependu/fastify-nodemailer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-nodemailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-nodemailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-nodemailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-nodemailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lependu","download_url":"https://codeload.github.com/lependu/fastify-nodemailer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-nodemailer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266187175,"owners_count":23889926,"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":["fastify","fastifyjs-plugin","nodejs","nodemailer"],"created_at":"2024-08-04T15:00:37.146Z","updated_at":"2025-07-20T19:32:42.318Z","avatar_url":"https://github.com/lependu.png","language":"JavaScript","funding_links":[],"categories":["\u003ch2 align=\"center\"\u003eAwesome Fastify\u003c/h2\u003e","JavaScript"],"sub_categories":["\u003ch2 align=\"center\"\u003eEcosystem\u003c/h2\u003e"],"readme":"# fastify-nodemailer\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\n[![Build Status](https://travis-ci.org/lependu/fastify-nodemailer.svg?branch=master)](https://travis-ci.org/lependu/fastify-nodemailer)\n[![Known Vulnerabilities](https://snyk.io/test/github/lependu/fastify-nodemailer/badge.svg)](https://snyk.io/test/github/lependu/fastify-nodemailer)\n[![Coverage Status](https://coveralls.io/repos/github/lependu/fastify-nodemailer/badge.svg?branch=master)](https://coveralls.io/github/lependu/fastify-nodemailer?branch=master)\n![](https://img.shields.io/github/v/tag/lependu/fastify-nodemailer?label=latest)\n![npm](https://img.shields.io/npm/dm/fastify-nodemailer.svg)\n\n\nFastify nodemailer plugin, with this you can share the same nodemailer transporter in every part of your server.\n\nUnder the hood the it wraps [nodemailer](https://github.com/nodemailer/nodemailer) transporter and the options that you pass to `register` will be passed to the transporter. For configuration/usage details please check the [nodemailer documentation](https://nodemailer.com/usage/).\n\n## Install\n```\nnpm i fastify-nodemailer --save\n```\n\n## Versions\n\nThe plugin supports the following `Fastify` and `Nodemailer` versions. Please refer to corresponding branch in PR and issues.\n\nversion | branch | fastify | nodemailer | End of support\n--------|--------|---------|------------|---------------  \n1.x | [1.x](https://github.com/lependu/fastify-nodemailer/tree/1.x) | 1.x | 4.x | EOL   \n2.x | [2.x](https://github.com/lependu/fastify-nodemailer/tree/2.x) | 2.x | 4.x | TBD  \n3.x | [master](https://github.com/lependu/fastify-nodemailer) | 2.x | 5.x | [Deprecated](https://github.com/nodemailer/nodemailer/issues/979)\n4.x | [4.x](https://github.com/lependu/fastify-nodemailer/tree/4.x) | 2.x | 6.x | TBD\n5.x | [master](https://github.com/lependu/fastify-nodemailer) | 3.x | 6.x | TBD\n\n## Usage\nAdd it to you project with `register` and you are done!\nYou can access the transporter via `fastify.nodemailer` and *sendMail()* via `fastify.nodemailer.sendMail()`.\n```js\nconst fastify = require('fastify')()\n\nfastify.register(require('fastify-nodemailer'), {\n  pool: true,\n  host: 'smtp.example.com',\n  port: 465,\n  secure: true, // use TLS\n  auth: {\n      user: 'username',\n      pass: 'password'\n  }\n})\n\nfastify.get('/sendmail/:email', (req, reply, next) =\u003e {\n  let { nodemailer } = fastify\n  let recipient = req.params.email\n\n  nodemailer.sendMail({\n    from: 'sender@example.com',\n    to: recipient,\n    subject: 'foo',\n    text: 'bar'\n  }, (err, info) =\u003e {\n    if (err) next(err)\n    reply.send({\n      messageId: info.messageId\n    })\n  })\n})\n\nfastify.listen(3000, err =\u003e {\n  if (err) throw err\n  console.log(`server listening on ${fastify.server.address().port}`)\n})\n```\n## Custom transports\n\nBy default, passing an object as options to the plugin will configure nodemailer's main transport (SMTP).\n\nIf you need a custom transport, simply initialize the transport, and pass it to the plugin instead of an options object. For example, using the `nodemailer-sparkpost-transport`:\n\n```js\nconst fastify = require('fastify')()\n\nconst sparkPostTransport = require('nodemailer-sparkpost-transport')\n\nconst sparkPostTransportOptions = {\n  sparkPostApiKey: 'MY_API_KEY'\n}\n\nfastify.register(require('fastify-nodemailer'), sparkPostTransport(sparkPostTransportOptions))\n\n// or\n\nconst sparkPostTransportInstance = sparkPostTransport(sparkPostTransportOptions)\n\nfastify.register(require('fastify-nodemailer'), sparkPostTransportInstance)\n```\n\nThen, later:\n\n```js\nfastify.get('/sendmail', (req, reply, next) =\u003e {\n\n  const sendOptions = {\n    content: {\n      template_id: 'my_template_id',\n      use_draft_template: false\n    },\n    \"recipients\": [\n      {\n        \"address\": {\n          \"email\": \"sender@example.com\",\n          \"name\": \"John Doe\"\n        },\n        \"substitution_data\": {\n          username: \"John Doe\"\n        }\n      }\n    ]\n  };\n\n  fastify.nodemailer.sendMail(sendOptions, (err, info) =\u003e {\n    if (err) next(err)\n    reply.send({\n      messageId: info.messageId\n    })\n  })\n\n})\n```\n\n## Multiple transports\n\nSince fastify-nodemailer fully supports Fastify's built-in [encapsulation](https://www.fastify.io/docs/latest/Plugins-Guide/#register) feature, all you need to do is register this plugin with your custom transporter and the corresponding route in a new context.\n\n## License\n\nLicensed under [MIT](./LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flependu%2Ffastify-nodemailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flependu%2Ffastify-nodemailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flependu%2Ffastify-nodemailer/lists"}