Sleep

Vue- Email - Vue.js Nourished

.Vue-email is encouraged by react-email, it allows our company develop templates utilizing the vue structure, along with parts that assist our company create templates simply and quick.To begin utilizing vue-email in any sort of vue task, you merely need to have to install the package:.With NPM:.$ npm put in vue-email.With Yarn:.$ anecdote include vue-email.With PNPM:.$ pnpm install vue-email.Producing email layout.Develop a brand-new e-mail theme in wherever you intend to possess your layouts, for this situation, we can easily generate a theme directory, with a template gotten in touch with welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue component library for structure receptive e-mails.Viewpoint on GitHub.Happy coding!David Arenas.
Rendering the templates.We may utilize the make functionality, it obtains two params, the very first one is actually the design template to make, and also the 2nd the params to become utilized for the layout, and after that pass the outcome template in the body of request.Passing the template in the body, give our company the odds of providing utilizing any sort of web server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send email along with nodemailer.Directed email.
Deliver e-mail.Within this instance i using nuxt v3 because it allows us to specify api inside own venture, and also specify multiple api routes.Listed here our experts merely draw out the theme of the request body system, as well as deliver the email passing the design template in the sendMail functionality of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (event) =&gt const physical body = await readBody( occasion).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello world',.html: body.template,..await transporter.sendMail( possibilities). ).If you are not making use of the web server in nuxt, you may easily implement on any type of structure for instance making use of reveal:.import express coming 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 template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi world',.html: template,..wait for transporter.sendMail( options).return res.json( notification: "Email sent" ). ).app.listen( 3001 ).Records.Acquire the complete information [listed here] ().Components.You may see the parts, listed below:.Combinations.Emails developed with vue-email could be exchanged HTML or.clear text, as well as sent using any sort of e-mail company. You can see.instances listed below:.