.Vue-email is actually encouraged by react-email, it allows our company produce templates using the vue framework, along with elements that assist our team develop themes simply and also swiftly.To start utilizing vue-email in any vue task, you only need to have to put up the package deal:.Along with NPM:.$ npm install vue-email.With Anecdote:.$ yarn incorporate vue-email.With PNPM:.$ pnpm set up vue-email.Making e-mail template.Produce a new email theme in anywhere you would like to possess your themes, for this situation, our company can generate a design template file, along with a design template gotten in touch with welcome.vue.src/templates/welcome. vue.
name, welcome to vue-email.A Vue part library for property reactive emails.Scenery on GitHub.Satisfied coding!David Arenas.
Rendering the design templates.Our team can use the make functionality, it gets two params, the very first one is the theme to make, as well as the 2nd the params to become used for the theme, and then pass the result theme in the physical body of request.Passing the design template in the body, provide our team the opportunity of leaving using any hosting server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Send email with nodemailer.Posted email.
Send out e-mail.Within this example i using nuxt v3 considering that it permits our team to set api inside very own venture, as well as determine a number of api courses.Listed below we only remove the theme of the request physical body, and also send the e-mail passing the template in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) => const physical body = await readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.protected: inaccurate,.auth: customer: testAccount.user,.pass: testAccount.pass,.,. ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi there planet',.html: body.template,..wait for transporter.sendMail( options). ).If you are actually certainly not making use of the server in nuxt, you may conveniently carry out on any structure as an example using convey:.import show coming from 'express'.import nodemailer from 'nodemailer'.const app = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: incorrect,.auth: consumer: testAccount.user,.pass: testAccount.pass,.,. ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings globe',.html: layout,..wait for transporter.sendMail( options).profit res.json( information: "Email sent out" ). ).app.listen( 3001 ).Records.Obtain the complete information [listed here] ().Elements.You may see the parts, listed below:.Assimilations.Emails constructed with vue-email may be converted into HTML or even.clear text, and sent making use of any kind of e-mail service provider. You can easily find.instances listed here:.