Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually motivated through react-email, it allows our company make themes using the vue framework, along with parts that aid our team construct layouts quickly and also swiftly.To start using vue-email in any sort of vue project, you just need to have to put up the plan:.With NPM:.$ npm put in vue-email.Along with Anecdote:.$ yarn incorporate vue-email.With PNPM:.$ pnpm put up vue-email.Developing e-mail theme.Generate a new e-mail template in anywhere you would like to possess your themes, for this case, our experts can easily produce a layout directory, with a design template phoned welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue component collection for building reactive emails.Scenery on GitHub.Satisfied coding!David Arenas.
Rendering the design templates.Our experts can easily use the leave functionality, it gets pair of params, the very first one is the theme to render, and the 2nd the params to become utilized for the layout, and after that pass the result theme in the body of ask for.Passing the template in the body, offer our company the possibility of providing utilizing any server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Send out email along with nodemailer.Routed email.
Send email.In this example i utilizing nuxt v3 because it permits us to specify api inside personal job, and determine numerous api paths.Here our company simply draw out the template of the ask for physical body, and send out the email passing the template in the sendMail functionality of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const physical body = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( lot: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi there world',.html: body.template,..await transporter.sendMail( alternatives). ).If you are not making use of the hosting server in nuxt, you may quickly implement on any type of platform for example making use of express:.import reveal from 'reveal'.import nodemailer from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings planet',.html: theme,..wait for transporter.sendMail( possibilities).profit res.json( message: "Email sent" ). ).app.listen( 3001 ).Paperwork.Obtain the complete documents [below] ().Elements.You can view the parts, listed below:.Combinations.E-mails constructed along with vue-email may be converted into HTML or even.plain text, and also sent utilizing any type of e-mail company. You can view.examples listed below:.

Articles You Can Be Interested In