Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually motivated through react-email, it enables us create themes using the vue structure, with components that assist us build templates simply and fast.To begin utilizing vue-email in any vue venture, you only require to set up the plan:.Along with NPM:.$ npm put in vue-email.Along with Yarn:.$ yarn include vue-email.Along with PNPM:.$ pnpm put in vue-email.Creating e-mail template.Generate a brand-new email layout in anywhere you would like to possess your design templates, for this case, our team can easily produce a template directory, with a theme phoned welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue element collection for property receptive emails.Scenery on GitHub.Pleased coding!David Arenas.
Providing the layouts.Our team can easily use the leave functionality, it obtains pair of params, the first one is actually the design template to provide, and also the 2nd the params to become made use of for the layout, and then pass the result design template in the physical body of demand.Passing the design template in the physical body, provide us the chance of making making use of any kind of server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver e-mail along with nodemailer.Routed e-mail.
Send email.In this example i making use of nuxt v3 due to the fact that it permits us to prepare api inside very own job, as well as specify a number of api paths.Listed below our experts simply draw out the design template of the demand body system, as well as deliver the e-mail passing the template in the sendMail feature of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body = wait for readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello world',.html: body.template,..await transporter.sendMail( choices). ).If you are actually not making use of the web server in nuxt, you can quickly execute on any structure for instance making use of reveal:.import share coming from 'show'.bring in nodemailer coming from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( lot: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings world',.html: layout,..await transporter.sendMail( options).gain res.json( message: "Email delivered" ). ).app.listen( 3001 ).Documentation.Acquire the complete documents [listed here] ().Components.You can easily view the components, listed here:.Assimilations.Emails created along with vue-email could be converted into HTML or.plain text, and also sent out making use of any type of e-mail specialist. You can view.examples listed below:.