Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually influenced through react-email, it enables our team generate templates utilizing the vue structure, with elements that help our company build layouts easily as well as quickly.To begin making use of vue-email in any vue task, you simply need to set up the package deal:.With NPM:.$ npm set up vue-email.Along with Anecdote:.$ yarn add vue-email.Along with PNPM:.$ pnpm put in vue-email.Making email theme.Make a brand-new e-mail template in any place you want to have your layouts, for this case, our experts can easily make a layout directory, with a design template gotten in touch with welcome.vue.src/templates/welcome. vue.

name, welcome to vue-email.A Vue part collection for property receptive emails.Scenery on GitHub.Pleased coding!David Arenas.
Making the themes.We can make use of the make function, it gets 2 params, the 1st one is actually the design template to make, and the second the params to be made use of for the layout, and after that pass the outcome theme in the body of demand.Passing the theme in the body system, give us the possibility of leaving utilizing any kind of server, reveal, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Dispatched email.
Deliver email.In this instance i using nuxt v3 due to the fact that it allows our company to prepare api inside very own venture, and also specify several api options.Below we merely extract the design template of the demand physical body, as well as send the e-mail passing the layout in the sendMail functionality of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const physical body = await readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hello globe',.html: body.template,..await transporter.sendMail( options). ).If you are not using the server in nuxt, you may simply carry out on any kind of structure as an example using reveal:.import convey 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( 'smtp.ethereal.email',.port: 587,.secure: false,.auth: individual: testAccount.user,.successfully pass: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hey there planet',.html: template,..await transporter.sendMail( options).gain res.json( message: "Email sent" ). ).app.listen( 3001 ).Documentation.Obtain the total documentation [below] ().Components.You can easily view the components, listed below:.Combinations.E-mails constructed with vue-email may be converted into HTML or even.clear text, as well as sent out utilizing any sort of e-mail specialist. You can find.instances here:.

Articles You Can Be Interested In