Sleep

Vue- Email - Vue.js Feed

.Vue-email is motivated through react-email, it allows us develop layouts utilizing the vue framework, along with parts that assist our team create layouts conveniently and fast.To begin utilizing vue-email in any sort of vue task, you merely need to have to put up the deal:.Along with NPM:.$ npm mount vue-email.With Anecdote:.$ yarn add vue-email.Along with PNPM:.$ pnpm put up vue-email.Developing e-mail layout.Produce a brand new email template in no matter where you want to possess your layouts, for this instance, our company can produce a theme folder, with a template gotten in touch with welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue part collection for building responsive emails.View on GitHub.Happy coding!David Arenas.
Rendering the themes.Our team can easily use the render functionality, it gets 2 params, the 1st one is actually the template to leave, as well as the 2nd the params to become made use of for the theme, and after that pass the end result template in the body system of demand.Passing the layout in the physical body, offer our company the odds of rendering making use of any kind of web server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail with nodemailer.Delivered email.
Deliver email.In this particular example i using nuxt v3 given that it enables our company to specify api inside personal job, and define a number of api options.Listed here our team only draw out the design template of the request body, as well as deliver the e-mail passing the layout in the sendMail function of the nodemailer package.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (event) =&gt const body system = await readBody( occasion).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: false,.auth: customer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hey there planet',.html: body.template,..wait for transporter.sendMail( options). ).If you are actually certainly not utilizing the web server in nuxt, you can quickly execute on any kind of structure as an example utilizing reveal:.import express from 'express'.import nodemailer coming from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello planet',.html: design template,..await transporter.sendMail( options).profit res.json( information: "Email delivered" ). ).app.listen( 3001 ).Information.Receive the full records [listed below] ().Parts.You can view the components, listed below:.Assimilations.Emails developed with vue-email could be converted into HTML or.clear text, and sent out making use of any type of email provider. You can see.instances here:.