Sleep

Vue- Email - Vue.js Nourished

.Vue-email is motivated through react-email, it enables our team generate themes utilizing the vue framework, with elements that help us develop themes effortlessly and also swiftly.To begin making use of vue-email in any kind of vue job, you merely need to mount the plan:.With NPM:.$ npm put up vue-email.Along with Yarn:.$ yarn add vue-email.With PNPM:.$ pnpm put in vue-email.Generating e-mail template.Produce a brand-new e-mail layout in no matter where you wish to possess your templates, for this scenario, we can create a theme file, with a theme contacted welcome.vue.src/templates/welcome. vue.

title, invited to vue-email.A Vue part collection for structure reactive e-mails.Sight on GitHub.Pleased coding!David Arenas.
Leaving the themes.Our company may use the render functionality, it gets 2 params, the first one is the layout to provide, and also the 2nd the params to become utilized for the template, and afterwards pass the outcome template in the body of ask for.Passing the design template in the physical body, provide us the opportunity of making utilizing any type of hosting server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Send e-mail with nodemailer.Posted e-mail.
Send out e-mail.In this instance i making use of nuxt v3 since it allows our company to establish api inside own job, and also describe numerous api courses.Here our team only extract the theme of the demand physical body, and send out the e-mail passing the design template in the sendMail function of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const body = await readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( bunch: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello there planet',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually certainly not utilizing the server in nuxt, you can conveniently carry out on any framework for example using share:.import show from 'share'.bring in nodemailer from 'nodemailer'.const app = 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,.safe and secure: false,.auth: customer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings globe',.html: theme,..await transporter.sendMail( alternatives).yield res.json( information: "Email sent" ). ).app.listen( 3001 ).Documents.Obtain the total records [right here] ().Parts.You can easily observe the elements, listed here:.Combinations.Emails developed with vue-email could be converted into HTML or.clear text, as well as delivered using any sort of email provider. You can easily find.instances listed here:.

Articles You Can Be Interested In