Sleep

Vue- Email - Vue.js Feed

.Vue-email is motivated through react-email, it permits us produce templates utilizing the vue platform, along with components that aid us build templates quickly as well as fast.To begin making use of vue-email in any type of vue project, you simply need to have to put up the bundle:.Along with NPM:.$ npm put up vue-email.With Yarn:.$ anecdote add vue-email.With PNPM:.$ pnpm put up vue-email.Making email template.Develop a brand new e-mail template in no matter where you desire to possess your templates, for this scenario, our experts can easily generate a design template directory, with a template gotten in touch with welcome.vue.src/templates/welcome. vue.

label, welcome to vue-email.A Vue component collection for property receptive emails.Scenery on GitHub.Delighted coding!David Arenas.
Rendering the layouts.Our experts can use the render feature, it receives 2 params, the 1st one is actually the design template to make, and also the second the params to become made use of for the design template, and afterwards pass the end result layout in the body system of request.Passing the layout in the body, give our team the odds of making utilizing any server, express, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Provided email.
Deliver email.In this instance i using nuxt v3 because it allows our company to specify api inside very own job, as well as determine multiple api courses.Listed here our team merely draw out the theme of the demand body system, and send the e-mail passing the theme in the sendMail function of the nodemailer package.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body = wait for readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi there planet',.html: body.template,..await transporter.sendMail( possibilities). ).If you are actually certainly not using the web server in nuxt, you can quickly carry out on any kind of structure for instance utilizing show:.import share 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 carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: false,.auth: customer: testAccount.user,.pass: testAccount.pass,.,. ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings world',.html: template,..wait for transporter.sendMail( alternatives).gain res.json( message: "Email sent" ). ).app.listen( 3001 ).Information.Acquire the total records [listed here] ().Components.You can easily view the elements, listed here:.Integrations.E-mails developed with vue-email could be converted into HTML or even.plain text, and also sent out making use of any kind of email company. You may view.instances listed here:.