Sleep

Vue- Email - Vue.js Supplied

.Vue-email is inspired by react-email, it permits us develop themes using the vue platform, with elements that help our company develop templates simply and also quick.To begin utilizing vue-email in any type of vue project, you only need to have to set up the bundle:.With NPM:.$ npm put up vue-email.Along with Yarn:.$ yarn add vue-email.With PNPM:.$ pnpm set up vue-email.Producing email design template.Make a brand-new e-mail design template in everywhere you intend to have your layouts, for this scenario, our experts can easily generate a layout directory, along with a layout called welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue component collection for building reactive emails.Sight on GitHub.Satisfied coding!David Arenas.
Making the layouts.We can easily utilize the leave functionality, it receives pair of params, the initial one is actually the layout to render, and the second the params to be used for the design template, and after that pass the end result theme in the physical body of request.Passing the template in the physical body, give our company the odds of leaving using any kind of server, show, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver email along with nodemailer.Sent e-mail.
Send out e-mail.Within this example i making use of nuxt v3 given that it allows our team to prepare api inside very own task, and also define several api paths.Listed below our team simply draw out the template of the ask for physical body, as well as send the email passing the layout in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (activity) =&gt const physical body = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello planet',.html: body.template,..await transporter.sendMail( alternatives). ).If you are not making use of the web server in nuxt, you may conveniently implement on any type of structure as an example utilizing convey:.import reveal from 'show'.bring in nodemailer coming from 'nodemailer'.const app = share().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( host: process.env.HOST ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello there world',.html: theme,..await transporter.sendMail( alternatives).yield res.json( information: "Email sent" ). ).app.listen( 3001 ).Paperwork.Obtain the full records [below] ().Parts.You can view the elements, listed here:.Assimilations.E-mails developed with vue-email could be converted into HTML or even.plain text, and sent out utilizing any kind of email service provider. You can see.instances listed here:.