Sleep

Vue- Email - Vue.js Supplied

.Vue-email is influenced through react-email, it enables our team develop themes making use of the vue structure, with parts that assist us develop themes simply as well as swiftly.To start making use of vue-email in any type of vue project, you just need to put in the deal:.Along with NPM:.$ npm install vue-email.Along with Yarn:.$ anecdote add vue-email.With PNPM:.$ pnpm mount vue-email.Creating email layout.Develop a brand-new e-mail theme in no matter where you wish to possess your themes, for this instance, our company can generate a template folder, along with a design template called welcome.vue.src/templates/welcome. vue.

title, appreciated to vue-email.A Vue part library for structure responsive e-mails.Sight on GitHub.Happy coding!David Arenas.
Rendering the layouts.Our experts can utilize the render function, it acquires pair of params, the 1st one is the layout to make, as well as the second the params to be made use of for the theme, and then pass the end result design template in the body system of request.Passing the theme in the body system, provide our company the odds of making utilizing any sort of hosting server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email along with nodemailer.Directed email.
Deliver email.In this particular example i using nuxt v3 considering that it allows us to specify api inside very own venture, as well as specify multiple api paths.Below our team merely remove the template of the ask for physical body, and also send the e-mail passing the layout in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body system = await readBody( celebration).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: false,.auth: consumer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello globe',.html: body.template,..await transporter.sendMail( alternatives). ).If you are certainly not using the hosting server in nuxt, you can simply execute on any type of framework for example utilizing reveal:.bring express coming from 'convey'.bring in nodemailer from 'nodemailer'.const app = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings planet',.html: layout,..await transporter.sendMail( choices).gain res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Documents.Obtain the total records [listed below] ().Parts.You may see the parts, listed here:.Assimilations.E-mails built with vue-email can be converted into HTML or even.clear text, and also sent out utilizing any kind of email service provider. You can easily find.examples listed here:.

Articles You Can Be Interested In