Sleep

Vue- Email - Vue.js Supplied

.Vue-email is motivated through react-email, it enables our team make layouts making use of the vue platform, with components that assist us develop design templates effortlessly and also quickly.To start making use of vue-email in any vue job, you merely require to set up the deal:.Along with NPM:.$ npm put up vue-email.With Yarn:.$ anecdote include vue-email.Along with PNPM:.$ pnpm mount vue-email.Developing email layout.Create a brand-new e-mail template in wherever you wish to possess your design templates, for this case, our experts can easily create a design template file, with a design template contacted welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue element library for property receptive emails.Scenery on GitHub.Pleased coding!David Arenas.
Leaving the templates.Our team can use the leave functionality, it obtains 2 params, the initial one is the design template to provide, and also the 2nd the params to become made use of for the layout, and then pass the outcome design template in the body of request.Passing the template in the body, give our company the opportunity of providing making use of any sort of server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email along with nodemailer.Emailed email.
Send out email.Within this example i utilizing nuxt v3 considering that it permits us to set api inside personal project, and also specify various api options.Listed below our team merely remove the layout of the ask for physical body, and also deliver the email passing the design template in the sendMail function of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (activity) =&gt const physical body = await readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there planet',.html: body.template,..await transporter.sendMail( choices). ).If you are certainly not utilizing the web server in nuxt, you can quickly implement on any type of platform as an example utilizing show:.bring express from 'express'.bring in nodemailer coming from 'nodemailer'.const application = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: inaccurate,.auth: consumer: testAccount.user,.pass: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there globe',.html: template,..await transporter.sendMail( possibilities).yield res.json( message: "Email sent" ). ).app.listen( 3001 ).Documents.Receive the complete information [right here] ().Components.You may see the parts, listed here:.Assimilations.Emails constructed along with vue-email can be exchanged HTML or even.clear text, and sent using any sort of e-mail company. You may view.instances here:.