Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually encouraged by react-email, it enables us develop layouts utilizing the vue framework, along with elements that aid our company build layouts quickly as well as quickly.To begin utilizing vue-email in any type of vue task, you just need to have to set up the deal:.Along with NPM:.$ npm mount vue-email.Along with Anecdote:.$ anecdote incorporate vue-email.Along with PNPM:.$ pnpm mount vue-email.Generating email design template.Develop a new email layout in everywhere you would like to have your design templates, for this case, our team may generate a layout folder, with a design template phoned welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue element library for property responsive emails.View on GitHub.Pleased coding!David Arenas.
Rendering the layouts.Our team can use the leave feature, it obtains 2 params, the very first one is the design template to render, as well as the second the params to be made use of for the template, and afterwards pass the outcome layout in the body system of request.Passing the template in the body system, give us the possibility of leaving using any kind of web server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Send email along with nodemailer.Emailed e-mail.
Send out e-mail.In this particular example i making use of nuxt v3 considering that it permits our team to prepare api inside personal venture, and also describe multiple api courses.Right here our experts simply remove the design template of the demand body system, and send out the e-mail passing the design template in the sendMail feature of the nodemailer package deal.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (event) =&gt const body = await readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hello there world',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are not utilizing the server in nuxt, you may effortlessly carry out on any framework for example making use of express:.bring reveal from 'share'.import nodemailer from 'nodemailer'.const application = express().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( 'smtp.ethereal.email',.slot: 587,.safe and secure: incorrect,.auth: individual: testAccount.user,.successfully pass: testAccount.pass,.,. ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings globe',.html: design template,..await transporter.sendMail( options).profit res.json( information: "Email delivered" ). ).app.listen( 3001 ).Paperwork.Obtain the complete paperwork [right here] ().Components.You can easily view the parts, listed below:.Combinations.Emails created with vue-email could be exchanged HTML or even.clear text, and delivered using any sort of email provider. You can easily see.instances here:.