Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually inspired by react-email, it permits us generate templates utilizing the vue platform, along with elements that help our company build design templates quickly and quick.To begin making use of vue-email in any sort of vue task, you only need to have to install the package:.With NPM:.$ npm mount vue-email.Along with Anecdote:.$ anecdote add vue-email.With PNPM:.$ pnpm put up vue-email.Generating email template.Produce a brand new e-mail template in anywhere you intend to possess your design templates, for this situation, we can easily produce a template folder, along with a template contacted welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue component library for building receptive e-mails.Perspective on GitHub.Happy coding!David Arenas.
Leaving the layouts.We can easily utilize the leave functionality, it acquires pair of params, the very first one is the design template to make, and also the 2nd the params to be utilized for the layout, and then pass the end result theme in the body of demand.Passing the layout in the physical body, give our company the chance of providing making use of any sort of server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send e-mail along with nodemailer.Mailed email.
Send out email.In this particular example i utilizing nuxt v3 since it permits our company to specify api inside own venture, as well as describe various api paths.Right here our experts only remove the theme of the request physical body, as well as deliver the e-mail passing the design template in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const physical body = await readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.protected: misleading,.auth: user: testAccount.user,.successfully pass: testAccount.pass,.,. ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there planet',.html: body.template,..wait for transporter.sendMail( choices). ).If you are certainly not making use of the web server in nuxt, you may easily carry out on any kind of framework as an example making use of express:.import reveal coming from 'share'.import nodemailer coming from 'nodemailer'.const app = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi globe',.html: theme,..await transporter.sendMail( possibilities).yield res.json( message: "Email sent" ). ).app.listen( 3001 ).Paperwork.Acquire the total records [below] ().Parts.You can easily find the parts, listed here:.Integrations.E-mails constructed along with vue-email could be converted into HTML or even.clear text, and also delivered making use of any sort of email company. You can easily view.examples listed here:.

Articles You Can Be Interested In