Sleep

Vue- Email - Vue.js Supplied

.Vue-email is motivated by react-email, it allows us develop layouts using the vue platform, with elements that aid our team construct layouts easily as well as quickly.To begin utilizing vue-email in any vue task, you merely need to have to put in the package deal:.With NPM:.$ npm mount vue-email.With Anecdote:.$ yarn incorporate vue-email.Along with PNPM:.$ pnpm put in vue-email.Producing email template.Create a brand-new email template in any place you want to possess your layouts, for this instance, our company can easily generate a design template directory, with a layout gotten in touch with welcome.vue.src/templates/welcome. vue.

name, welcome to vue-email.A Vue part public library for building responsive e-mails.View on GitHub.Delighted coding!David Arenas.
Leaving the layouts.Our team may utilize the render function, it obtains two params, the initial one is the template to make, as well as the 2nd the params to become made use of for the design template, and after that pass the outcome theme in the body of ask for.Passing the theme in the physical body, give our team the possibility of rendering utilizing any server, show, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email with nodemailer.Dispatched email.
Send email.Within this instance i utilizing nuxt v3 due to the fact that it enables our team to prepare api inside very own venture, and describe various api paths.Listed below our team merely draw out the layout of the request body, and also send the email passing the design template in the sendMail feature of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (event) =&gt const physical body = await readBody( event).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe and secure: misleading,.auth: user: testAccount.user,.elapsed: testAccount.pass,.,. ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi world',.html: body.template,..await transporter.sendMail( choices). ).If you are certainly not utilizing the hosting server in nuxt, you may effortlessly execute on any structure as an example making use of reveal:.bring express from 'share'.import nodemailer from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe: incorrect,.auth: user: testAccount.user,.pass: testAccount.pass,.,. ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello there world',.html: layout,..await transporter.sendMail( options).profit res.json( message: "Email sent" ). ).app.listen( 3001 ).Documentation.Obtain the full documentation [listed here] ().Components.You can view the parts, listed below:.Combinations.E-mails developed with vue-email can be exchanged HTML or.plain text, and also delivered using any sort of e-mail provider. You can easily observe.examples below:.