Sleep

Vue- Email - Vue.js Feed

.Vue-email is inspired by react-email, it allows our team generate layouts using the vue structure, along with parts that aid us build design templates easily as well as quick.To begin using vue-email in any type of vue venture, you just require to put in the plan:.Along with NPM:.$ npm set up vue-email.With Yarn:.$ yarn include vue-email.Along with PNPM:.$ pnpm set up vue-email.Making e-mail theme.Develop a brand new e-mail template in anywhere you would like to possess your design templates, for this case, we can easily create a layout directory, with a theme contacted welcome.vue.src/templates/welcome. vue.

label, welcome to vue-email.A Vue part collection for building reactive e-mails.Sight on GitHub.Delighted coding!David Arenas.
Rendering the design templates.We may utilize the render function, it receives pair of params, the first one is the theme to provide, and also the second the params to become used for the template, and afterwards pass the end result template in the body system of request.Passing the design template in the body, provide us the odds of leaving making use of any kind of web server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out e-mail along with nodemailer.Posted email.
Send e-mail.Within this instance i utilizing nuxt v3 due to the fact that it allows our team to specify api inside very own task, and also specify various api paths.Here our team just extract the design template of the ask for physical body, and also send the email passing the design template in the sendMail feature of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body = wait for readBody( event).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi there world',.html: body.template,..wait for transporter.sendMail( options). ).If you are actually certainly not utilizing the server in nuxt, you can quickly execute on any platform as an example making use of express:.import reveal from 'show'.import nodemailer from 'nodemailer'.const app = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings globe',.html: template,..await transporter.sendMail( possibilities).profit res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Documentation.Get the complete documentation [listed here] ().Components.You can easily view the parts, listed here:.Combinations.Emails developed with vue-email could be converted into HTML or even.clear text, as well as sent utilizing any kind of email provider. You may observe.examples below:.