Sleep

Vue- Email - Vue.js Nourished

.Vue-email is inspired through react-email, it permits us make themes using the vue platform, with components that aid us construct layouts quickly and also fast.To begin utilizing vue-email in any sort of vue venture, you merely need to put up the deal:.With NPM:.$ npm install vue-email.With Yarn:.$ anecdote add vue-email.Along with PNPM:.$ pnpm install vue-email.Developing e-mail theme.Create a new email template in everywhere you wish to possess your layouts, for this scenario, we can develop a template directory, with a theme contacted welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue component collection for structure reactive emails.Perspective on GitHub.Delighted coding!David Arenas.
Leaving the layouts.Our experts can easily make use of the provide functionality, it gets 2 params, the initial one is the template to leave, as well as the 2nd the params to become made use of for the theme, and then pass the result layout in the physical body of request.Passing the design template in the body system, give our team the possibility of rendering utilizing any sort of hosting server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send e-mail with nodemailer.Delivered e-mail.
Send email.Within this instance i utilizing nuxt v3 because it permits our team to set api inside own job, and define a number of api options.Listed here our company simply remove the layout of the demand physical body, and send the e-mail passing the theme in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body system = wait for readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello there planet',.html: body.template,..await transporter.sendMail( possibilities). ).If you are actually certainly not making use of the server in nuxt, you can simply apply on any structure for instance utilizing express:.bring convey from 'share'.bring in nodemailer from 'nodemailer'.const application = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: inaccurate,.auth: individual: testAccount.user,.successfully pass: testAccount.pass,.,. ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi there globe',.html: template,..wait for transporter.sendMail( choices).return res.json( message: "Email sent out" ). ).app.listen( 3001 ).Documents.Acquire the total information [right here] ().Elements.You can easily find the components, listed here:.Assimilations.Emails created along with vue-email could be exchanged HTML or.clear text, as well as sent making use of any email company. You can easily see.instances listed below:.