Sleep

Vue- Email - Vue.js Feed

.Vue-email is inspired by react-email, it enables us generate design templates making use of the vue structure, with parts that aid our company create design templates quickly as well as quickly.To begin utilizing vue-email in any vue task, you only need to set up the plan:.Along with NPM:.$ npm put up vue-email.Along with Anecdote:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm put in vue-email.Creating e-mail layout.Develop a new e-mail template in any place you wish to possess your themes, for this instance, we can easily make a design template directory, with a layout called welcome.vue.src/templates/welcome. vue.

label, invited to vue-email.A Vue part public library for property receptive e-mails.Sight on GitHub.Satisfied coding!David Arenas.
Rendering the design templates.Our experts can easily make use of the provide function, it receives pair of params, the 1st one is actually the template to make, and the 2nd the params to be utilized for the template, and then pass the end result layout in the body of request.Passing the layout in the physical body, offer our team the opportunity of leaving utilizing any kind of web server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email along with nodemailer.Posted e-mail.
Deliver email.In this example i using nuxt v3 considering that it permits us to specify api inside personal project, and determine numerous api routes.Listed here our experts just draw out the template of the ask for physical body, and deliver the email passing the template in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (event) =&gt const body = await readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( lot: process.env.HOST ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there planet',.html: body.template,..await transporter.sendMail( choices). ).If you are actually certainly not using the web server in nuxt, you may effortlessly apply on any kind of platform as an example using convey:.import show from 'show'.bring in nodemailer coming from 'nodemailer'.const app = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello planet',.html: layout,..await transporter.sendMail( alternatives).gain res.json( message: "Email sent" ). ).app.listen( 3001 ).Paperwork.Acquire the complete documents [right here] ().Elements.You can see the components, listed below:.Assimilations.E-mails developed along with vue-email could be exchanged HTML or even.plain text, and sent using any type of email company. You can easily see.instances listed below:.