.Vue-email is motivated by react-email, it allows us generate design templates making use of the vue platform, with parts that assist us build layouts easily and quick.To start utilizing vue-email in any kind of vue job, you merely need to have to install the package:.With NPM:.$ npm install vue-email.With Anecdote:.$ anecdote include vue-email.Along with PNPM:.$ pnpm set up vue-email.Developing email theme.Develop a brand new e-mail design template in wherever you want to have your templates, for this instance, our company can easily produce a layout directory, with a design template called welcome.vue.src/templates/welcome. vue.
title, invited to vue-email.A Vue part public library for property reactive emails.Viewpoint on GitHub.Delighted coding!David Arenas.
Leaving the templates.Our company may utilize the make function, it receives 2 params, the very first one is actually the layout to render, and the second the params to be used for the template, and afterwards pass the outcome template in the physical body of request.Passing the theme in the body, give our company the possibility of making using any kind of server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail along with nodemailer.Emailed e-mail.
Deliver email.In this instance i utilizing nuxt v3 since it allows our team to specify api inside very own project, as well as specify numerous api routes.Right here our company merely extract the design template of the request body, as well as send out the e-mail passing the theme in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) => const body = wait for readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi there globe',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are actually certainly not utilizing the server in nuxt, you may conveniently execute on any type of structure as an example making use of reveal:.import show from 'show'.import nodemailer from 'nodemailer'.const application = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const design template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( lot: process.env.HOST ).const options = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hello there globe',.html: layout,..wait for transporter.sendMail( choices).profit res.json( message: "Email delivered" ). ).app.listen( 3001 ).Information.Receive the full documents [here] ().Components.You may observe the components, listed here:.Assimilations.E-mails created along with vue-email can be exchanged HTML or even.clear text, as well as delivered using any kind of e-mail service provider. You can see.examples below:.