Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually motivated by react-email, it permits our team make design templates using the vue platform, with parts that aid us construct templates easily and also quick.To start using vue-email in any kind of vue venture, you merely need to have to put in the package:.With NPM:.$ npm mount vue-email.With Yarn:.$ yarn incorporate vue-email.Along with PNPM:.$ pnpm put in vue-email.Producing e-mail design template.Produce a new email layout in no matter where you would like to possess your themes, for this situation, our team can create a design template directory, with a template gotten in touch with welcome.vue.src/templates/welcome. vue.

title, invited to vue-email.A Vue element library for building responsive emails.Perspective on GitHub.Delighted coding!David Arenas.
Rendering the layouts.Our experts may use the leave functionality, it obtains 2 params, the 1st one is actually the template to provide, and also the 2nd the params to be made use of for the theme, and afterwards pass the result layout in the physical body of ask for.Passing the design template in the physical body, offer our team the odds of leaving using any sort of server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email along with nodemailer.Routed e-mail.
Deliver e-mail.Within this instance i making use of nuxt v3 since it enables our company to establish api inside very own venture, and also specify various api routes.Below our company only remove the theme of the request body, as well as send out the email passing the layout in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body = await readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi planet',.html: body.template,..wait for transporter.sendMail( options). ).If you are not making use of the web server in nuxt, you may conveniently implement on any sort of structure as an example making use of express:.import convey from 'show'.import nodemailer coming from 'nodemailer'.const app = show().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( lot: process.env.HOST ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello world',.html: theme,..await transporter.sendMail( options).profit res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Information.Get the full documents [listed below] ().Parts.You can observe the elements, listed here:.Combinations.Emails constructed along with vue-email may be converted into HTML or.clear text, and also sent using any kind of email provider. You can view.instances listed below:.