Sleep

Vue- Email - Vue.js Supplied

.Vue-email is inspired through react-email, it enables us develop layouts utilizing the vue structure, with parts that aid our company build design templates simply and fast.To start making use of vue-email in any vue project, you simply require to install the package:.Along with NPM:.$ npm install vue-email.Along with Anecdote:.$ yarn incorporate vue-email.With PNPM:.$ pnpm install vue-email.Making email design template.Produce a brand new email template in no matter where you wish to possess your layouts, for this scenario, our company can easily develop a template file, along with a theme contacted welcome.vue.src/templates/welcome. vue.

name, welcome to vue-email.A Vue element library for building reactive e-mails.Perspective on GitHub.Delighted coding!David Arenas.
Making the themes.Our experts can utilize the render functionality, it receives 2 params, the 1st one is the theme to render, as well as the 2nd the params to be used for the layout, and afterwards pass the outcome theme in the physical body of ask for.Passing the layout in the body system, provide our team the opportunity of rendering making use of any sort of web server, reveal, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out e-mail along with nodemailer.Provided email.
Deliver email.Within this instance i utilizing nuxt v3 because it enables our company to set api inside very own job, and also describe several api options.Listed here we simply draw out the design template of the demand body system, and also deliver the email passing the layout in the sendMail feature of the nodemailer package.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body system = await readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there planet',.html: body.template,..await transporter.sendMail( possibilities). ).If you are certainly not using the web server in nuxt, you can easily implement on any kind of framework for instance using reveal:.bring express coming from 'convey'.import nodemailer coming from 'nodemailer'.const app = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hello there planet',.html: template,..await transporter.sendMail( alternatives).profit res.json( information: "Email sent" ). ).app.listen( 3001 ).Paperwork.Acquire the full documents [here] ().Components.You may observe the parts, listed below:.Combinations.E-mails developed with vue-email may be exchanged HTML or even.plain text, and also sent out utilizing any email provider. You can easily observe.examples below:.

Articles You Can Be Interested In