Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually influenced through react-email, it allows our company develop themes making use of the vue framework, with elements that assist us build templates quickly and quick.To begin utilizing vue-email in any type of vue task, you merely need to have to set up the plan:.With NPM:.$ npm install vue-email.With Yarn:.$ anecdote include vue-email.With PNPM:.$ pnpm put in vue-email.Developing e-mail layout.Generate a brand-new e-mail layout in wherever you desire to possess your layouts, for this scenario, our company can make a design template file, with a theme gotten in touch with welcome.vue.src/templates/welcome. vue.

title, appreciated to vue-email.A Vue element public library for structure responsive e-mails.Sight on GitHub.Satisfied coding!David Arenas.
Providing the design templates.Our company may utilize the render function, it gets pair of params, the initial one is actually the theme to leave, as well as the 2nd the params to become used for the design template, and then pass the result layout in the body of request.Passing the theme in the body, provide our team the odds of leaving using any web server, reveal, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver email along with nodemailer.Dispatched email.
Send out email.In this particular example i utilizing nuxt v3 since it allows our company to set api inside personal venture, and describe numerous api options.Listed below we only extract the template of the ask for body system, and send the e-mail passing the design template in the sendMail function of the nodemailer package.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body = wait for readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( lot: process.env.HOST ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi planet',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually not utilizing the server in nuxt, you can simply carry out on any structure as an example making use of show:.bring share from 'show'.bring in nodemailer 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 transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: false,.auth: user: testAccount.user,.pass: testAccount.pass,.,. ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello there globe',.html: design template,..wait for transporter.sendMail( options).profit res.json( notification: "Email sent" ). ).app.listen( 3001 ).Records.Get the total documentation [listed below] ().Elements.You may view the components, listed here:.Assimilations.E-mails constructed with vue-email could be exchanged HTML or.plain text, and also sent out utilizing any type of e-mail company. You may observe.instances here:.

Articles You Can Be Interested In