Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually encouraged by react-email, it enables our team make themes using the vue structure, along with components that help our team construct themes effortlessly as well as swiftly.To begin making use of vue-email in any type of vue venture, you only require to install the package deal:.With NPM:.$ npm put up vue-email.Along with Yarn:.$ yarn add vue-email.With PNPM:.$ pnpm set up vue-email.Generating e-mail layout.Develop a new email theme in wherever you intend to have your layouts, for this case, our team may create a design template folder, along with a layout phoned welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue element collection for building receptive emails.Scenery on GitHub.Happy coding!David Arenas.
Leaving the design templates.Our experts can easily use the make feature, it obtains 2 params, the very first one is actually the template to render, and the 2nd the params to be utilized for the template, and afterwards pass the outcome layout in the body of ask for.Passing the layout in the body system, offer our company the odds of rendering using any kind of hosting server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Provided email.
Send email.Within this example i using nuxt v3 considering that it allows our company to prepare api inside personal venture, as well as define multiple api routes.Listed below our team simply extract the layout of the ask for body, as well as send the email passing the theme in the sendMail functionality of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body = wait for readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( lot: process.env.HOST ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi globe',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually certainly not utilizing the server in nuxt, you may effortlessly apply on any structure for instance utilizing show:.import convey coming from 'share'.import nodemailer from 'nodemailer'.const app = express().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( 'smtp.ethereal.email',.slot: 587,.safe: inaccurate,.auth: user: testAccount.user,.pass: testAccount.pass,.,. ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings globe',.html: design template,..wait for transporter.sendMail( options).profit res.json( notification: "Email sent out" ). ).app.listen( 3001 ).Information.Acquire the total documents [here] ().Elements.You can easily find the components, listed below:.Integrations.E-mails constructed along with vue-email may be exchanged HTML or even.plain text, and delivered utilizing any type of e-mail company. You may see.instances right here:.

Articles You Can Be Interested In