Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually inspired through react-email, it allows our company generate themes making use of the vue platform, with elements that assist our company develop themes conveniently and also quickly.To start using vue-email in any kind of vue job, you just need to have to set up the package:.Along with NPM:.$ npm mount vue-email.Along with Yarn:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm put in vue-email.Generating e-mail theme.Produce a new email layout in any place you wish to possess your layouts, for this scenario, we can easily develop a template folder, with a design template phoned welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue part public library for structure receptive emails.Viewpoint on GitHub.Delighted coding!David Arenas.
Rendering the templates.Our experts may make use of the render function, it obtains 2 params, the very first one is actually the template to render, and also the second the params to become used for the layout, and afterwards pass the outcome theme in the body of request.Passing the template in the body system, offer our company the odds of making utilizing any type of server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Send email with nodemailer.Emailed email.
Deliver email.In this example i making use of nuxt v3 due to the fact that it allows us to specify api inside very own project, and specify various api options.Below our experts only extract the template of the demand body, and deliver the e-mail passing the theme in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body = wait for readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings planet',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are certainly not utilizing the server in nuxt, you can conveniently carry out on any sort of structure as an example making use of express:.bring reveal from 'show'.bring in nodemailer from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( lot: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello world',.html: layout,..wait for transporter.sendMail( choices).profit res.json( message: "Email delivered" ). ).app.listen( 3001 ).Documents.Get the total documentation [right here] ().Parts.You can find the elements, listed here:.Integrations.Emails constructed along with vue-email could be converted into HTML or.clear text, and also delivered making use of any kind of e-mail specialist. You may view.instances below:.

Articles You Can Be Interested In