Sleep

Vue- Email - Vue.js Nourished

.Vue-email is inspired by react-email, it permits us produce templates using the vue platform, with elements that help our company build themes quickly as well as swiftly.To start using vue-email in any kind of vue venture, you just require to set up the package deal:.With NPM:.$ npm mount vue-email.Along with Yarn:.$ yarn include vue-email.Along with PNPM:.$ pnpm put in vue-email.Making e-mail design template.Create a new email design template in everywhere you wish to possess your layouts, for this instance, our experts can develop a template directory, with a design template gotten in touch with welcome.vue.src/templates/welcome. vue.

title, appreciated to vue-email.A Vue part library for building responsive e-mails.Sight on GitHub.Happy coding!David Arenas.
Rendering the design templates.Our company may make use of the render functionality, it acquires two params, the very first one is the design template to make, as well as the second the params to be used for the layout, and afterwards pass the end result design template in the physical body of ask for.Passing the layout in the physical body, provide our team the opportunity of leaving utilizing any kind of hosting server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Send e-mail along with nodemailer.Mailed email.
Deliver email.In this particular instance i making use of nuxt v3 because it allows us to set api inside own task, and also define various api paths.Right here our company simply remove the layout of the request body, and also deliver the e-mail passing the design template in the sendMail functionality of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (event) =&gt const body system = await readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( lot: process.env.HOST ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi planet',.html: body.template,..await transporter.sendMail( possibilities). ).If you are actually not making use of the server in nuxt, you can conveniently execute on any sort of platform for example using share:.import convey coming from 'express'.bring in nodemailer coming from 'nodemailer'.const app = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: misleading,.auth: user: testAccount.user,.successfully pass: testAccount.pass,.,. ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings globe',.html: layout,..wait for transporter.sendMail( options).yield res.json( information: "Email delivered" ). ).app.listen( 3001 ).Documents.Get the complete paperwork [listed below] ().Elements.You may see the elements, listed here:.Integrations.Emails developed with vue-email may be exchanged HTML or even.plain text, and also sent utilizing any sort of e-mail specialist. You may find.examples below:.

Articles You Can Be Interested In