Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually encouraged by react-email, it permits us generate templates using the vue platform, with parts that help our company create templates quickly as well as fast.To start making use of vue-email in any sort of vue project, you simply need to put up the package deal:.Along with NPM:.$ npm set up vue-email.With Anecdote:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm set up vue-email.Making e-mail design template.Produce a brand new email layout in wherever you intend to possess your templates, for this situation, our company can easily generate a theme folder, with a theme gotten in touch with welcome.vue.src/templates/welcome. vue.

name, welcome to vue-email.A Vue element library for property responsive e-mails.Perspective on GitHub.Satisfied coding!David Arenas.
Providing the templates.Our experts can easily use the render function, it obtains two params, the 1st one is actually the theme to make, and the second the params to become used for the design template, and then pass the result template in the body system of request.Passing the template in the body, offer us the chance of rendering utilizing any kind of server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Send out email with nodemailer.Dispatched email.
Send out e-mail.In this particular instance i using nuxt v3 due to the fact that it permits our team to prepare api inside personal project, and specify several api routes.Right here our company only extract the layout of the request body system, and also send the email passing the template in the sendMail function of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body = wait for readBody( occasion).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( multitude: process.env.HOST ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there globe',.html: body.template,..wait for transporter.sendMail( choices). ).If you are certainly not making use of the web server in nuxt, you may conveniently execute on any type of framework as an example using reveal:.import convey coming from 'share'.bring in nodemailer from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe and secure: false,.auth: customer: testAccount.user,.pass: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi globe',.html: layout,..wait for transporter.sendMail( options).gain res.json( information: "Email sent out" ). ).app.listen( 3001 ).Information.Acquire the total paperwork [here] ().Parts.You can easily see the components, listed here:.Assimilations.E-mails constructed with vue-email can be exchanged HTML or.plain text, and also sent out using any kind of e-mail company. You may view.instances listed here:.