.Vue-email is motivated through react-email, it allows us create templates using the vue framework, with components that assist us build templates simply and swiftly.To begin using vue-email in any sort of vue task, you only require to put in the plan:.Along with NPM:.$ npm set up vue-email.With Yarn:.$ anecdote include vue-email.With PNPM:.$ pnpm put in vue-email.Developing email layout.Create a brand-new e-mail design template in everywhere you intend to possess your templates, for this case, we can easily produce a layout folder, with a template phoned welcome.vue.src/templates/welcome. vue.
label, welcome to vue-email.A Vue element library for building receptive emails.Perspective on GitHub.Pleased coding!David Arenas.
Leaving the design templates.Our team may make use of the provide functionality, it acquires pair of params, the first one is actually the theme to leave, and also the 2nd the params to be utilized for the template, and afterwards pass the end result template in the body system of request.Passing the template in the body system, give our company the possibility of making making use of any sort of web server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail with nodemailer.Posted e-mail.
Deliver email.In this particular example i utilizing nuxt v3 since it enables us to set api inside very own task, as well as define various api courses.Listed below we merely extract the template of the demand body system, and send the e-mail passing the template in the sendMail functionality of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) => const body = wait for readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: misleading,.auth: customer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hey there world',.html: body.template,..wait for transporter.sendMail( options). ).If you are actually certainly not using the web server in nuxt, you can easily apply on any type of framework for example using reveal:.bring convey from 'express'.import nodemailer coming from 'nodemailer'.const application = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const design template = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: misleading,.auth: individual: testAccount.user,.successfully pass: testAccount.pass,.,. ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hello planet',.html: layout,..wait for transporter.sendMail( possibilities).gain res.json( notification: "Email sent" ). ).app.listen( 3001 ).Documentation.Obtain the total information [here] ().Components.You can easily see the components, listed below:.Combinations.Emails created with vue-email could be exchanged HTML or even.clear text, and sent using any type of e-mail service provider. You may view.instances below:.