Sleep

Vue- Email - Vue.js Supplied

.Vue-email is motivated by react-email, it allows us create themes utilizing the vue framework, along with parts that assist our team develop themes simply and fast.To start using vue-email in any type of vue task, you just need to have to mount the deal:.With NPM:.$ npm install vue-email.Along with Anecdote:.$ anecdote include vue-email.Along with PNPM:.$ pnpm mount vue-email.Producing e-mail design template.Develop a brand-new email template in anywhere you want to possess your design templates, for this situation, we can create a theme directory, with a layout gotten in touch with welcome.vue.src/templates/welcome. vue.

title, invited to vue-email.A Vue component library for structure reactive e-mails.Sight on GitHub.Satisfied coding!David Arenas.
Rendering the themes.Our company can easily make use of the provide feature, it receives 2 params, the very first one is the theme to leave, and the second the params to be made use of for the theme, and afterwards pass the end result theme in the physical body of request.Passing the design template in the body system, provide our team the chance of rendering making use of any hosting server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail with nodemailer.Emailed email.
Send email.In this instance i utilizing nuxt v3 since it permits our company to set api inside personal task, as well as determine numerous api paths.Here our company simply draw out the theme of the request physical body, and deliver the email passing the layout in the sendMail feature of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (activity) =&gt const physical body = await readBody( occasion).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi there planet',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are not utilizing the hosting server in nuxt, you may easily carry out on any framework for example utilizing show:.bring reveal from 'show'.import nodemailer from 'nodemailer'.const application = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings world',.html: theme,..wait for transporter.sendMail( possibilities).yield res.json( message: "Email sent" ). ).app.listen( 3001 ).Documents.Acquire the full records [listed below] ().Parts.You can observe the elements, listed below:.Assimilations.Emails created along with vue-email may be converted into HTML or.clear text, as well as sent utilizing any sort of e-mail specialist. You can see.instances below:.

Articles You Can Be Interested In