{"id":31447326,"url":"https://github.com/asjas/fastify-nodemailer","last_synced_at":"2026-01-20T17:37:17.323Z","repository":{"id":314780032,"uuid":"1051306870","full_name":"Asjas/fastify-nodemailer","owner":"Asjas","description":"Fastify plugin for Nodemailer that includes TypeScript types","archived":false,"fork":false,"pushed_at":"2025-09-28T21:56:14.000Z","size":123,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-28T23:27:14.692Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/Asjas.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-05T19:07:12.000Z","updated_at":"2025-09-28T21:56:17.000Z","dependencies_parsed_at":"2025-09-14T19:32:22.556Z","dependency_job_id":"83659490-4bf0-405e-8740-e48d0c9171c9","html_url":"https://github.com/Asjas/fastify-nodemailer","commit_stats":null,"previous_names":["asjas/fastify-nodemailer"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Asjas/fastify-nodemailer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asjas%2Ffastify-nodemailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asjas%2Ffastify-nodemailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asjas%2Ffastify-nodemailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asjas%2Ffastify-nodemailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Asjas","download_url":"https://codeload.github.com/Asjas/fastify-nodemailer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asjas%2Ffastify-nodemailer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277778127,"owners_count":25875423,"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","status":"online","status_checked_at":"2025-09-30T02:00:09.208Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-10-01T01:05:23.603Z","updated_at":"2025-10-01T01:05:25.310Z","avatar_url":"https://github.com/Asjas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @asjas/fastify-nodemailer\n\nA Fastify plugin to integrate [Nodemailer](https://nodemailer.com/) for sending emails. This plugin allows you to share a single Nodemailer transporter instance across your Fastify server, simplifying email functionality in your application.\n\n## Features\n\n- Seamless integration with Fastify's plugin system.\n- Share a single Nodemailer transporter across your server.\n- Support for SMTP connection pooling for improved performance.\n- Compatibility with Fastify's encapsulation for multiple transports.\n- TypeScript support for type-safe development.\n\n## Install\n\n```bash\nnpm i --save-exact @asjas/fastify-nodemailer\n```\n\n## Compatibility\n\nThe plugin supports the following `Fastify` and `Nodemailer` versions.\n\nNPM Version | Branch | Fastify | Nodemailer | End of support\n--------|--------|---------|------------|---------------\n1.x | [main](https://github.com/asjas/fastify-nodemailer) | 5.x | 7.x | TBD\n\n## Usage\n\nRegister the plugin with your Fastify server and provide Nodemailer transport options. The options passed to `register` are forwarded to Nodemailer's `createTransport` function. Refer to the [Nodemailer documentation](https://nodemailer.com/usage/) for detailed configuration options.\n\n### Example\n\n```js\nimport Fastify from 'fastify';\nimport fastifyNodemailerPlugin from '@asjas/fastify-nodemailer';\n\nconst fastify = Fastify();\n\nfastify.register(fastifyNodemailerPlugin, {\n  host: 'smtp.example.com',\n  port: 587,\n  secure: false, // Use true for port 465, false for other ports\n  auth: {\n    user: 'your-email@example.com',\n    pass: 'your-password',\n  },\n});\n\n// Example route to send an email\nfastify.post('/send-email', async (request, reply) =\u003e {\n  try {\n    const info = await fastify.nodemailer.sendMail({\n      from: 'sender@example.com',\n      to: 'recipient@example.com',\n      subject: 'Test Email',\n      text: 'This is a test email!',\n    });\n    return { message: 'Email sent', info };\n  } catch (err) {\n    fastify.log.error('Error sending email:', err);\n    reply.status(500).send({ error: 'Failed to send email' });\n  }\n});\n\nfastify.listen({ port: 3000 }, (err) =\u003e {\n  if (err) throw err;\n  console.log('Server running on http://localhost:3000');\n});\n```\n\n## Connection Pooling\n\nFor applications sending multiple emails, you can enable SMTP connection pooling to improve performance by reusing connections. Configure pooling by setting `pool: true` and related options:\n\n```js\nfastify.register(fastifyNodemailerPlugin, {\n  host: 'smtp.example.com',\n  port: 587,\n  secure: false,\n  auth: {\n    user: 'your-email@example.com',\n    pass: 'your-password',\n  },\n  pool: true, // Enable connection pooling\n  maxConnections: 5, // Maximum concurrent connections (default: 5)\n  maxMessages: 50, // Maximum messages per connection (default: 100)\n  rateLimit: 5, // Maximum 5 emails per second\n  rateDelta: 1000, // Rate limit window (1 second)\n});\n```\n\nSee the [Nodemailer SMTP documentation](https://nodemailer.com/smtp/pooled/) for more details on pooling options.\n\n## Multiple Transports\n\nThanks to Fastify's [encapsulation](https://www.fastify.io/docs/latest/Reference/Encapsulation/), you can register multiple instances of the plugin with different transporters in separate contexts. For example:\n\n```js\nfastify.register(async (instance) =\u003e {\n  instance.register(fastifyNodemailerPlugin, {\n    host: 'smtp.service1.com',\n    port: 587,\n    secure: false,\n    auth: {\n      user: 'user1@service1.com',\n      pass: 'password1',\n    },\n  });\n  instance.post('/send-email-service1', async (request, reply) =\u003e {\n    // Use service1 transporter\n    await instance.nodemailer.sendMail({ /* email options */ });\n  });\n});\n\nfastify.register(async (instance) =\u003e {\n  instance.register(fastifyNodemailerPlugin, {\n    host: 'smtp.service2.com',\n    port: 587,\n    secure: false,\n    auth: {\n      user: 'user2@service2.com',\n      pass: 'password2',\n    },\n  });\n  instance.post('/send-email-service2', async (request, reply) =\u003e {\n    // Use service2 transporter\n    await instance.nodemailer.sendMail({ /* email options */ });\n  });\n});\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasjas%2Ffastify-nodemailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasjas%2Ffastify-nodemailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasjas%2Ffastify-nodemailer/lists"}