Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually encouraged by react-email, it enables our company generate design templates utilizing the vue structure, along with elements that help us develop templates quickly as well as fast.To begin utilizing vue-email in any type of vue job, you merely need to have to put up the package deal:.Along with NPM:.$ npm put up vue-email.With Anecdote:.$ anecdote add vue-email.With PNPM:.$ pnpm put in vue-email.Creating e-mail design template.Make a new e-mail layout in no matter where you want to possess your themes, for this instance, our experts can generate a layout folder, along with a layout called welcome.vue.src/templates/welcome. vue.

name, welcome to vue-email.A Vue part public library for building reactive e-mails.View on GitHub.Satisfied coding!David Arenas.
Providing the layouts.We can easily use the render functionality, it obtains 2 params, the initial one is the design template to render, and the second the params to become used for the layout, and then pass the outcome template in the physical body of demand.Passing the layout in the physical body, give our company the opportunity of rendering using any hosting server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send e-mail with nodemailer.Posted email.
Deliver e-mail.In this particular instance i using nuxt v3 due to the fact that it enables our company to specify api inside own task, and also describe several api routes.Below our team only extract the template of the ask for body, and also send the e-mail passing the template in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (activity) =&gt const physical body = await readBody( event).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi world',.html: body.template,..await transporter.sendMail( possibilities). ).If you are actually certainly not making use of the web server in nuxt, you may conveniently carry out on any type of structure for instance using show:.import convey coming from 'show'.bring in nodemailer from 'nodemailer'.const application = reveal().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 transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.protected: false,.auth: individual: testAccount.user,.successfully pass: testAccount.pass,.,. ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi world',.html: theme,..await transporter.sendMail( choices).return res.json( message: "Email sent" ). ).app.listen( 3001 ).Documents.Get the full paperwork [listed below] ().Components.You can easily view the elements, listed below:.Assimilations.E-mails built with vue-email can be converted into HTML or.clear text, as well as sent using any e-mail specialist. You may see.examples listed here:.