Sleep

Vue- Email - Vue.js Feed

.Vue-email is actually encouraged through react-email, it enables us produce design templates utilizing the vue structure, with components that assist our team build themes simply and also quickly.To begin using vue-email in any vue task, you simply require to put up the deal:.Along with NPM:.$ npm install vue-email.Along with Anecdote:.$ yarn incorporate vue-email.With PNPM:.$ pnpm put in vue-email.Developing e-mail template.Generate a brand-new email layout in everywhere you want to possess your layouts, for this instance, our experts may make a layout file, with a template phoned welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue component library for building responsive emails.View on GitHub.Pleased coding!David Arenas.
Making the templates.We can utilize the make functionality, it gets 2 params, the 1st one is the layout to render, as well as the second the params to be used for the template, and afterwards pass the result layout in the physical body of demand.Passing the template in the body, offer us the chance of leaving utilizing any web server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail with nodemailer.Delivered e-mail.
Send e-mail.In this instance i making use of nuxt v3 due to the fact that it enables us to set api inside personal job, and also determine numerous api courses.Right here our team just draw out the theme of the demand physical body, as well as send the e-mail 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 system = wait for readBody( occasion).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: incorrect,.auth: individual: testAccount.user,.elapsed: testAccount.pass,.,. ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi there planet',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually not utilizing the server in nuxt, you can simply apply on any type of platform for example utilizing convey:.import express coming from 'share'.import nodemailer coming from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello there planet',.html: layout,..wait for transporter.sendMail( possibilities).return res.json( message: "Email sent" ). ).app.listen( 3001 ).Documentation.Receive the complete records [below] ().Components.You can easily observe the parts, listed below:.Assimilations.Emails constructed along with vue-email may be exchanged HTML or.plain text, and also sent making use of any type of email specialist. You can easily observe.examples right here:.