Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually encouraged through react-email, it enables us generate layouts utilizing the vue structure, along with parts that assist our company create themes conveniently and swiftly.To begin making use of vue-email in any vue job, you only need to have to mount the plan:.With NPM:.$ npm put in vue-email.With Yarn:.$ yarn add vue-email.With PNPM:.$ pnpm put up vue-email.Developing e-mail template.Create a brand-new email theme in any place you would like to have your templates, for this situation, our team can create a layout directory, with a design template contacted welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue part collection for property receptive emails.Viewpoint on GitHub.Happy coding!David Arenas.
Leaving the templates.Our experts can utilize the render feature, it receives pair of params, the first one is the layout to render, as well as the second the params to become made use of for the layout, and afterwards pass the result template in the body system of ask for.Passing the design template in the body system, provide our company the odds of making using any kind of hosting server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Send out email with nodemailer.Posted email.
Deliver email.In this example i making use of nuxt v3 because it allows our company to prepare api inside own task, and also specify multiple api paths.Listed here we only remove the design template of the ask for physical body, as well as deliver the email passing the template in the sendMail functionality of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (celebration) =&gt const body system = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe and secure: false,.auth: individual: testAccount.user,.elapsed: testAccount.pass,.,. ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there globe',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually certainly not using the server in nuxt, you can effortlessly execute on any type of structure for instance using share:.bring convey from 'share'.bring in 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 carrier = nodemailer.createTransport( lot: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hey there planet',.html: design template,..wait for transporter.sendMail( alternatives).return res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Records.Receive the total documentation [listed here] ().Components.You can find the parts, listed here:.Assimilations.E-mails developed along with vue-email could be converted into HTML or.plain text, and also delivered making use of any e-mail service provider. You can easily find.instances listed here:.

Articles You Can Be Interested In