Sleep

Vue- Email - Vue.js Feed

.Vue-email is actually encouraged through react-email, it allows our team generate themes making use of the vue structure, with components that assist us develop themes simply and quick.To start using vue-email in any kind of vue task, you only need to mount the deal:.With NPM:.$ npm put in vue-email.Along with Yarn:.$ yarn incorporate vue-email.Along with PNPM:.$ pnpm mount vue-email.Producing e-mail design template.Produce a new e-mail layout in any place you wish to possess your themes, for this case, our experts can create a theme directory, along with a design template called welcome.vue.src/templates/welcome. vue.

label, invited to vue-email.A Vue part library for structure receptive e-mails.Perspective on GitHub.Happy coding!David Arenas.
Rendering the themes.We can easily utilize the provide feature, it gets pair of params, the 1st one is the template to leave, and the 2nd the params to be used for the template, and afterwards pass the outcome theme in the body of demand.Passing the design template in the body, offer our team the possibility of leaving utilizing any kind of hosting server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail with nodemailer.Provided e-mail.
Send email.In this particular instance i utilizing nuxt v3 considering that it permits us to set api inside personal task, and also define numerous api options.Listed below our experts just draw out the template of the request physical body, and also send the e-mail passing the template in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (activity) =&gt const body system = wait for readBody( occasion).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( multitude: process.env.HOST ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi world',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are actually not utilizing the server in nuxt, you can easily apply on any type of structure for example utilizing share:.import express coming from 'share'.import nodemailer coming from 'nodemailer'.const application = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi there globe',.html: theme,..await transporter.sendMail( possibilities).return res.json( message: "Email delivered" ). ).app.listen( 3001 ).Records.Receive the total records [below] ().Parts.You can easily observe the components, listed below:.Assimilations.Emails developed with vue-email could be exchanged HTML or even.plain text, and sent out utilizing any type of email service provider. You can easily observe.examples listed here:.

Articles You Can Be Interested In