Sleep

Vue- Email - Vue.js Nourished

.Vue-email is encouraged by react-email, it allows us produce templates using the vue structure, with parts that assist us build templates conveniently and fast.To begin making use of vue-email in any vue task, you simply need to have to install the package:.Along with NPM:.$ npm mount vue-email.With Yarn:.$ anecdote add vue-email.With PNPM:.$ pnpm mount vue-email.Making e-mail template.Make a new email layout in any place you wish to possess your templates, for this situation, our experts can easily produce a template folder, with a template phoned welcome.vue.src/templates/welcome. vue.

label, invited to vue-email.A Vue component library for property receptive emails.Perspective on GitHub.Satisfied coding!David Arenas.
Leaving the design templates.Our team can utilize the render function, it receives two params, the very first one is the layout to make, and also the 2nd the params to be utilized for the design template, and afterwards pass the end result theme in the body system of demand.Passing the theme in the body system, offer us the possibility of providing making use of any type of web server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Send e-mail with nodemailer.Sent e-mail.
Deliver e-mail.In this particular example i using nuxt v3 due to the fact that it enables our company to set api inside own task, and determine several api routes.Listed below we merely draw out the design template of the ask for physical body, as well as send out the email passing the theme in the sendMail feature of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (activity) =&gt const body = await readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( host: process.env.HOST ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi world',.html: body.template,..wait for transporter.sendMail( options). ).If you are actually certainly not making use of the web server in nuxt, you may effortlessly execute on any platform for example utilizing convey:.bring reveal coming from 'show'.bring in nodemailer from 'nodemailer'.const app = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( multitude: process.env.HOST ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hey there globe',.html: layout,..await transporter.sendMail( alternatives).gain res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Documentation.Obtain the full paperwork [listed below] ().Parts.You can easily see the parts, listed here:.Integrations.E-mails constructed with vue-email may be exchanged HTML or.plain text, as well as sent out utilizing any sort of email specialist. You may see.examples listed below:.