Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually inspired through react-email, it allows our company create design templates using the vue framework, with elements that help us create layouts conveniently and also fast.To start utilizing vue-email in any sort of vue project, you just need to have to mount the package:.With NPM:.$ npm install vue-email.Along with Anecdote:.$ anecdote include vue-email.Along with PNPM:.$ pnpm put up vue-email.Creating email layout.Generate a brand new e-mail template in anywhere you intend to possess your themes, for this scenario, our experts can easily develop a design template directory, along with a design template gotten in touch with welcome.vue.src/templates/welcome. vue.

label, welcome to vue-email.A Vue part collection for structure receptive e-mails.View on GitHub.Happy coding!David Arenas.
Leaving the design templates.Our company can use the make feature, it gets 2 params, the 1st one is actually the template to make, as well as the second the params to be used for the design template, and after that pass the result template in the body of demand.Passing the layout in the physical body, offer our team the possibility of rendering using any sort of hosting server, show, fastify, nuxt in SSR, and so on src/pages/index. vue.Send email along with nodemailer.Placed email.
Deliver e-mail.In this particular instance i utilizing nuxt v3 because it enables us to establish api inside own project, and also define several api paths.Listed here our experts only remove the template of the ask for body system, and also deliver the email passing the theme in the sendMail functionality of the nodemailer package.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body system = wait for readBody( occasion).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello there world',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are not utilizing the server in nuxt, you can simply apply on any kind of framework for instance making use of express:.import reveal from 'show'.import nodemailer coming from 'nodemailer'.const application = convey().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( bunch: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi there world',.html: design template,..await transporter.sendMail( choices).yield res.json( notification: "Email sent" ). ).app.listen( 3001 ).Documentation.Get the complete documents [here] ().Elements.You may view the components, listed here:.Combinations.Emails developed along with vue-email can be exchanged HTML or even.plain text, and delivered using any sort of email specialist. You can easily view.instances listed below:.

Articles You Can Be Interested In