Sleep

Vue- Email - Vue.js Supplied

.Vue-email is inspired by react-email, it allows our team produce themes using the vue platform, along with components that help us create themes conveniently and quick.To start making use of vue-email in any vue venture, you simply need to put in the plan:.Along with NPM:.$ npm set up vue-email.With Anecdote:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm install vue-email.Creating e-mail design template.Make a brand-new e-mail layout in no matter where you want to possess your design templates, for this instance, our experts may generate a theme directory, with a layout gotten in touch with welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue element public library for building receptive emails.Viewpoint on GitHub.Satisfied coding!David Arenas.
Leaving the layouts.We can make use of the provide functionality, it acquires 2 params, the 1st one is the theme to render, as well as the second the params to be made use of for the theme, and after that pass the result template in the body of demand.Passing the layout in the body, provide our company the chance of rendering using any kind of web server, show, fastify, nuxt in SSR, etc src/pages/index. vue.Send e-mail with nodemailer.Sent email.
Send e-mail.Within this instance i using nuxt v3 since it allows our company to set api inside personal job, and also describe several api paths.Below our team just remove the layout of the request body system, as well as send out the e-mail passing the layout in the sendMail feature of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body system = wait for readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings planet',.html: body.template,..await transporter.sendMail( possibilities). ).If you are not making use of the hosting server in nuxt, you may quickly execute on any sort of platform for example making use of express:.import show from 'reveal'.import nodemailer from 'nodemailer'.const application = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( multitude: process.env.HOST ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi world',.html: design template,..wait for transporter.sendMail( alternatives).gain res.json( information: "Email sent out" ). ).app.listen( 3001 ).Documents.Obtain the total documents [here] ().Parts.You may observe the components, listed here:.Assimilations.Emails constructed along with vue-email may be exchanged HTML or even.plain text, and also sent utilizing any kind of e-mail specialist. You may see.instances listed here:.