fastify-nodemailer-plugin
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.3 • Public • Published

    fastify-nodemailer-plugin

    Version

    Nodemailer for Fastify

    Installation

    yarn add fastify-nodemailer-plugin
    or
    npm install fastify-nodemailer-plugin

    Usage

    Register config and example config and more nodemailer

    fastify.register(fastifyNodemailer, {
      service: "gmail",
      auth: {
        user: "testuser@gmail.com",
        pass: "secretpassword",
      },
    });

    If you use with TypeScript , you have to give this type to avoid error

    import Fastify, { FastifyInstance } from "fastify";
    
    const fastify: FastifyInstance = Fastify();

    Use with fastify decorate

    fastify.get("/", async (request, reply) => {
      fastify.nodemailer.sendMail({
        from: "testuser@gmail.com",
        to: request.body.email,
        subject: "Test User",
        text: "Hello World 👋",
      });
      return "Mail has send.";
    });

    Use with reply decorate

    fastify.get("/", async (request, reply) => {
      reply.nodemailer.sendMail({
        from: "testuser@gmail.com",
        to: request.body.email,
        subject: "Test User",
        text: "Hello World 👋",
      });
      return "Mail has send.";
    });

    Contributing

    Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

    Please make sure to update tests as appropriate.

    License

    MIT

    Install

    npm i fastify-nodemailer-plugin

    DownloadsWeekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    14.2 kB

    Total Files

    12

    Last publish

    Collaborators

    • urdux