Sleep

Vue- Email - Vue.js Nourished

.Vue-email is motivated through react-email, it permits us generate templates making use of the vue platform, with elements that assist us develop templates simply as well as quick.To start utilizing vue-email in any sort of vue project, you simply need to have to set up the bundle:.Along with NPM:.$ npm mount vue-email.Along with Yarn:.$ anecdote include vue-email.Along with PNPM:.$ pnpm set up vue-email.Making email layout.Produce a brand-new email layout in wherever you desire to possess your design templates, for this instance, we can easily create a template directory, along with a design template phoned welcome.vue.src/templates/welcome. vue.

label, welcome to vue-email.A Vue part public library for building receptive e-mails.Perspective on GitHub.Delighted coding!David Arenas.
Making the design templates.Our experts can easily make use of the make functionality, it obtains pair of params, the initial one is actually the design template to provide, and also the second the params to be utilized for the layout, and then pass the result design template in the body system of ask for.Passing the layout in the physical body, provide our team the odds of rendering making use of any kind of server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Send email with nodemailer.Shipped email.
Deliver email.In this example i making use of nuxt v3 since it allows our company to specify api inside own project, as well as specify several api options.Here our team simply draw out the design template of the request physical body, as well as send the e-mail passing the layout in the sendMail feature of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (activity) =&gt const body = await readBody( event).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi there globe',.html: body.template,..wait for transporter.sendMail( alternatives). ).If you are actually certainly not making use of the server in nuxt, you may effortlessly execute on any kind of framework for instance utilizing convey:.import express coming from 'reveal'.bring in nodemailer coming from 'nodemailer'.const application = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( lot: process.env.HOST ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings world',.html: theme,..await transporter.sendMail( choices).yield res.json( message: "Email sent" ). ).app.listen( 3001 ).Paperwork.Acquire the complete records [listed here] ().Parts.You can find the components, listed below:.Assimilations.E-mails developed along with vue-email can be converted into HTML or.clear text, and sent making use of any type of email provider. You can easily view.instances listed here:.