Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually motivated by react-email, it enables us produce themes utilizing the vue platform, along with components that help our team construct templates simply and also fast.To begin utilizing vue-email in any type of vue project, you merely need to install the bundle:.Along with NPM:.$ npm put in vue-email.Along with Yarn:.$ yarn incorporate vue-email.Along with PNPM:.$ pnpm put up vue-email.Generating email design template.Develop a brand new e-mail design template in everywhere you desire to possess your themes, for this case, our experts may create a theme directory, along with a design template called welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue element library for building receptive emails.Scenery on GitHub.Happy coding!David Arenas.
Rendering the design templates.We can utilize the make feature, it gets two params, the very first one is actually the template to make, and also the 2nd the params to be made use of for the design template, and afterwards pass the result layout in the body system of request.Passing the template in the body system, provide our company the possibility of leaving using any sort of hosting server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Send out email with nodemailer.Emailed e-mail.
Send email.In this example i using nuxt v3 since it permits our team to prepare api inside very own venture, and determine several api routes.Listed below our team only draw out the design template of the ask for body, and also send the e-mail passing the template in the sendMail feature of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const physical body = await readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello there globe',.html: body.template,..wait for transporter.sendMail( options). ).If you are certainly not utilizing the hosting server in nuxt, you may conveniently execute on any sort of framework as an example utilizing express:.bring share coming from 'reveal'.import nodemailer from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.secure: inaccurate,.auth: consumer: testAccount.user,.pass: testAccount.pass,.,. ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi world',.html: theme,..await transporter.sendMail( alternatives).profit res.json( notification: "Email sent out" ). ).app.listen( 3001 ).Documentation.Obtain the total information [here] ().Components.You can easily view the components, listed below:.Combinations.E-mails constructed with vue-email may be converted into HTML or even.clear text, and also sent utilizing any e-mail specialist. You can see.examples below:.