Sleep

Vue- Email - Vue.js Nourished

.Vue-email is motivated through react-email, it allows our team make design templates making use of the vue platform, along with parts that help our team construct layouts conveniently as well as fast.To begin making use of vue-email in any type of vue venture, you simply need to mount the plan:.Along with NPM:.$ npm mount vue-email.Along with Anecdote:.$ anecdote include vue-email.With PNPM:.$ pnpm put in vue-email.Generating email layout.Develop a brand-new e-mail design template in wherever you would like to possess your templates, for this scenario, our team may produce a template folder, along with a layout phoned welcome.vue.src/templates/welcome. vue.

name, welcome to vue-email.A Vue component library for structure reactive e-mails.Perspective on GitHub.Happy coding!David Arenas.
Rendering the templates.Our company can utilize the make feature, it receives pair of params, the very first one is the template to leave, and also the second the params to become utilized for the layout, and afterwards pass the end result template in the body of demand.Passing the design template in the body, give our team the odds of making making use of any kind of server, show, fastify, nuxt in SSR, and so on src/pages/index. vue.Send email with nodemailer.Mailed e-mail.
Deliver email.In this particular example i utilizing nuxt v3 since it allows our company to specify api inside own job, and also specify numerous api routes.Below our experts simply extract the theme of the ask for physical body, as well as send out the e-mail passing the design template in the sendMail function of the nodemailer package.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const physical 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',.target: 'greetings world',.html: body.template,..await transporter.sendMail( options). ).If you are certainly not making use of the web server in nuxt, you may simply carry out on any sort of framework for instance making use of show:.bring reveal from 'convey'.bring in nodemailer from 'nodemailer'.const application = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.target: 'greetings globe',.html: theme,..await transporter.sendMail( choices).yield res.json( message: "Email sent out" ). ).app.listen( 3001 ).Paperwork.Get the complete records [listed here] ().Elements.You may observe the parts, listed here:.Combinations.Emails built with vue-email may be exchanged HTML or even.plain text, and also delivered using any type of email specialist. You may find.instances right here:.