Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually influenced by react-email, it enables our team develop design templates utilizing the vue platform, with components that help us construct templates easily and also fast.To start utilizing vue-email in any sort of vue task, you simply require to put up the plan:.Along with NPM:.$ npm set up vue-email.Along with Anecdote:.$ yarn include vue-email.Along with PNPM:.$ pnpm install vue-email.Developing email template.Generate a brand new e-mail layout in any place you wish to possess your templates, for this case, our team may develop a layout directory, with a theme called welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue element collection for building reactive emails.Scenery on GitHub.Pleased coding!David Arenas.
Rendering the design templates.Our team can easily utilize the leave feature, it obtains pair of params, the first one is actually the template to render, and the 2nd the params to be utilized for the layout, and afterwards pass the outcome layout in the physical body of ask for.Passing the theme in the body, provide our team the opportunity of making utilizing any kind of web server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver email along with nodemailer.Provided email.
Deliver e-mail.In this particular instance i making use of nuxt v3 considering that it enables our company to prepare api inside personal project, and describe several api options.Right here we just draw out the layout of the ask for body, as well as send the e-mail passing the template in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const body = await readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( bunch: process.env.HOST ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings planet',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually certainly not making use of the server in nuxt, you can conveniently apply on any type of structure for instance using reveal:.import share from 'share'.bring in nodemailer from 'nodemailer'.const application = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( multitude: process.env.HOST ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings globe',.html: layout,..await transporter.sendMail( options).profit res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Documents.Obtain the complete information [right here] ().Elements.You may observe the parts, listed below:.Assimilations.Emails built along with vue-email may be exchanged HTML or even.plain text, as well as sent making use of any kind of e-mail provider. You can see.examples listed here:.