Sleep

Vue- Email - Vue.js Feed

.Vue-email is actually inspired by react-email, it allows us create templates using the vue framework, with parts that help our company construct design templates easily and also quickly.To start utilizing vue-email in any sort of vue task, you merely need to have to install the plan:.Along with NPM:.$ npm set up vue-email.With Anecdote:.$ yarn incorporate vue-email.With PNPM:.$ pnpm set up vue-email.Developing e-mail theme.Produce a brand-new email layout in no matter where you would like to have your design templates, for this scenario, our experts can easily make a design template directory, with a design template phoned welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue element public library for property receptive e-mails.Perspective on GitHub.Delighted coding!David Arenas.
Making the themes.Our experts may use the render function, it gets two params, the 1st one is the design template to leave, as well as the 2nd the params to be made use of for the theme, and then pass the outcome theme in the physical body of ask for.Passing the design template in the body system, give us the chance of making using any sort of server, express, fastify, nuxt in SSR, and so on src/pages/index. vue.Send email with nodemailer.Dispatched email.
Send email.In this particular example i making use of nuxt v3 considering that it permits our company to specify api inside own job, as well as describe numerous api options.Listed below our team simply extract the template of the ask for body system, and also send out the e-mail passing the theme in the sendMail functionality of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (activity) =&gt const physical body = wait for readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( multitude: process.env.HOST ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi there globe',.html: body.template,..wait for transporter.sendMail( alternatives). ).If you are actually certainly not using the web server in nuxt, you can quickly implement on any sort of platform as an example utilizing show:.bring show coming from 'reveal'.import nodemailer from 'nodemailer'.const app = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.protected: false,.auth: consumer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings world',.html: template,..await transporter.sendMail( choices).return res.json( message: "Email sent" ). ).app.listen( 3001 ).Documents.Get the full documents [listed here] ().Components.You can see the elements, listed below:.Combinations.Emails created along with vue-email can be exchanged HTML or even.plain text, as well as delivered making use of any sort of email provider. You can see.instances right here:.