{"id":18315538,"url":"https://github.com/mathieutu/nodemailer-react","last_synced_at":"2025-05-02T12:32:01.254Z","repository":{"id":33978279,"uuid":"165019040","full_name":"mathieutu/nodemailer-react","owner":"mathieutu","description":"A simple but powerfull Nodemailer wrapper to send email with React template.","archived":false,"fork":false,"pushed_at":"2022-01-28T10:58:11.000Z","size":314,"stargazers_count":25,"open_issues_count":8,"forks_count":17,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-19T04:14:56.153Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mathieutu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-10T08:15:52.000Z","updated_at":"2025-01-01T09:45:57.000Z","dependencies_parsed_at":"2022-07-20T15:17:55.114Z","dependency_job_id":null,"html_url":"https://github.com/mathieutu/nodemailer-react","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieutu%2Fnodemailer-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieutu%2Fnodemailer-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieutu%2Fnodemailer-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieutu%2Fnodemailer-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathieutu","download_url":"https://codeload.github.com/mathieutu/nodemailer-react/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252038227,"owners_count":21684655,"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-05T16:41:30.852Z","updated_at":"2025-05-02T12:31:57.065Z","avatar_url":"https://github.com/mathieutu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nodemailer React\n\n\nThis package aims to simplify the use of Nodemailer, along with React templating.\n\n## Installation\n\n```bash\nyarn add nodemailer-react\n```\n\nThis package has `nodemailer`, `react-dom` and `react` as Peer Dependencies,\nso you'll need to install them if you don't already have them:\n\n```bash\nyarn add nodemailer react-dom react\n```\n\n## Usage\n\nYou can find a full example in the [example](./example) folder,\nor see the [tests](./__tests__) to have more details.\n\n### Configure your SMTP transport\nAn object that defines your connection data.\nSee https://nodemailer.com/smtp/#general-options for details.\n\n```js\nconst transport = {\n  host: 'smtp.example.com',\n  secure: true,\n  auth: { user: 'username', pass: 'password' },\n}\n```\n\n### Configure your defaults\nAn object that is going to be merged into every message object.\nThis allows you to specify shared options, for example to set the same from address for every message.\nSee https://nodemailer.com/message/#common-fields\n\n```js\nconst defaults = {\n  from: \"sender@server.com\",\n}\n```\n\n### Create Email Components\nThey are basically functions which can take an object of props in parameter and return an object with :\n- The `subject` of the email, as string.\n- The `body` of the email, as JSX (ReactElement).\n\nThe have the following type:\n```ts\ntype Email = (props: object) =\u003e ({\n  subject: string;\n  body: ReactElement;\n})\n```\n\nExample:\n\n```jsx\nexport const WelcomeEmail = ({ firstName }) =\u003e ({\n  subject: `👋 ${firstName}`,\n  body: (\n    \u003cdiv\u003e\n      \u003cp\u003eHello {firstName}!\u003c/p\u003e\n      \u003cp\u003eHope you'll enjoy the package!\u003c/p\u003e\n    \u003c/div\u003e\n  )\n})\n\nexport const PasswordEmail = /* ... */\nexport const ReminderEmail = /* ... */\n```\n\n### Instantiate the `Mailer` function.\nIt takes your `transport` and `defaults` configuration as the first parameter,\nand a record of your emails components as the second.\n\n```js\nimport { Mailer } from 'nodemailer-react'\n\nexport const mailer = Mailer(\n  { transport, defaults },\n  { WelcomeEmail, PasswordEmail, ReminderEmail }\n)\n```\n\n_TIP: you can directly pass a transporter from nodemailer's `createTransport` method as first argument if you prefer._\n\n_TIP 2: you can alias your emails easily : `{ welcome: WelcomeEmail, pwd: PasswordEmail, ... }`._\n\n### Enjoy!\nSend mails in your application, by passing:\n- Your email template name: key of the email in the record you've provided to the Mailer.\n- The props of your email component.\n- The options of the email (to, from, attachments, etc.).\n  See https://nodemailer.com/message/#common-fields\n\n```js\nmailer.send('WelcomeEmail', { firstName: 'Mathieu' }, {\n  to: 'my@email.com'\n})\n```\n\n### Typescript\nEverything is fully typed, and you should have full autocompletion and type checking,\nwithin the options, but also components and props attached to them in `send` method.\n\nHowever, as Nodemailer does not publish its own types, be sure to install them from DefinitelyTyped repo:\n```bash\nyarn add -D @types/nodemailer\n```\n\n## License\nThis nodemailer-react package is an open-sourced software licensed under the MIT license.\n\n## Contributing\nIssues and PRs are obviously welcomed and encouraged, both for new features and documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieutu%2Fnodemailer-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathieutu%2Fnodemailer-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieutu%2Fnodemailer-react/lists"}