fastify-nodemailer-plugin
v1.0.3
Published
Nodemailer for Fastify
Downloads
14
Maintainers
Readme
fastify-nodemailer-plugin
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: "[email protected]",
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: "[email protected]",
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: "[email protected]",
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.