Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually motivated through react-email, it allows us produce templates utilizing the vue framework, along with elements that assist our company construct layouts easily and fast.To begin utilizing vue-email in any sort of vue job, you only need to have to mount the package deal:.With NPM:.$ npm put up vue-email.With Yarn:.$ anecdote add vue-email.With PNPM:.$ pnpm install vue-email.Making email layout.Create a new e-mail layout in wherever you wish to have your design templates, for this situation, our team can easily create a layout directory, along with a template phoned welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue element public library for structure responsive e-mails.Scenery on GitHub.Satisfied coding!David Arenas.
Leaving the templates.Our company can utilize the provide feature, it acquires pair of params, the very first one is actually the design template to make, and also the 2nd the params to be made use of for the template, and afterwards pass the outcome template in the body of ask for.Passing the layout in the body, provide us the possibility of leaving utilizing any sort of hosting server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Send e-mail with nodemailer.Shipped e-mail.
Send out email.In this particular instance i making use of nuxt v3 because it allows our team to establish api inside very own job, and determine numerous api options.Right here our experts only remove the layout of the demand body, and also deliver the email passing the design template in the sendMail functionality of the nodemailer package.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (activity) =&gt const physical body = await readBody( celebration).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe: inaccurate,.auth: consumer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings planet',.html: body.template,..wait for transporter.sendMail( choices). ).If you are certainly not using the hosting server in nuxt, you can quickly implement on any sort of framework for example making use of share:.import show coming from 'reveal'.import nodemailer coming from 'nodemailer'.const app = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( bunch: process.env.HOST ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi globe',.html: layout,..wait for transporter.sendMail( options).profit res.json( information: "Email sent" ). ).app.listen( 3001 ).Documents.Get the total documents [below] ().Elements.You can easily view the elements, listed here:.Combinations.E-mails built along with vue-email can be converted into HTML or.plain text, and also sent out utilizing any sort of email service provider. You can see.examples right here:.