Sleep

Vue- Email - Vue.js Supplied

.Vue-email is influenced through react-email, it permits our team develop templates using the vue structure, with parts that assist us build themes effortlessly as well as fast.To begin utilizing vue-email in any sort of vue venture, you merely require to install the bundle:.With NPM:.$ npm put up vue-email.With Yarn:.$ anecdote incorporate vue-email.Along with PNPM:.$ pnpm set up vue-email.Generating email layout.Make a new email template in anywhere you want to have your templates, for this situation, our company can easily generate a theme file, along with a design template called welcome.vue.src/templates/welcome. vue.

name, welcome to vue-email.A Vue element library for structure reactive e-mails.Viewpoint on GitHub.Delighted coding!David Arenas.
Leaving the layouts.Our company may utilize the render functionality, it obtains 2 params, the initial one is the template to make, as well as the 2nd the params to become utilized for the template, and afterwards pass the end result design template in the body system of request.Passing the template in the body, offer our team the opportunity of making making use of any server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email with nodemailer.Directed email.
Deliver e-mail.Within this instance i utilizing nuxt v3 given that it enables our company to prepare api inside own venture, and also specify a number of api courses.Listed below our team merely draw out the template of the demand body system, and send the email passing the design template in the sendMail functionality of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (activity) =&gt const physical body = wait for readBody( activity).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.secure: untrue,.auth: customer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there world',.html: body.template,..wait for transporter.sendMail( options). ).If you are certainly not utilizing the hosting server in nuxt, you can quickly implement on any type of framework as an example making use of share:.bring express coming from 'express'.bring in nodemailer from 'nodemailer'.const application = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: misleading,.auth: consumer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello there world',.html: theme,..await transporter.sendMail( possibilities).yield res.json( message: "Email sent" ). ).app.listen( 3001 ).Documents.Receive the complete records [here] ().Elements.You can easily see the parts, listed here:.Assimilations.E-mails built with vue-email may be converted into HTML or.plain text, and sent out using any email company. You can view.examples right here:.

Articles You Can Be Interested In