Sleep

Vue- Email - Vue.js Feed

.Vue-email is encouraged through react-email, it enables our team produce layouts utilizing the vue structure, with parts that assist our company build layouts quickly and also quick.To begin utilizing vue-email in any kind of vue project, you simply need to have to mount the deal:.With NPM:.$ npm install vue-email.Along with Yarn:.$ yarn incorporate vue-email.With PNPM:.$ pnpm set up vue-email.Creating email theme.Make a brand new e-mail layout in anywhere you would like to possess your design templates, for this situation, we may generate a template directory, with a layout called welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue element collection for property receptive e-mails.Perspective on GitHub.Pleased coding!David Arenas.
Rendering the templates.Our company may use the provide function, it gets pair of params, the first one is the theme to render, and the second the params to be made use of for the design template, and then pass the end result design template in the body system of demand.Passing the theme in the body, offer us the opportunity of providing utilizing any type of hosting server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Send e-mail with nodemailer.Provided e-mail.
Deliver email.Within this example i making use of nuxt v3 because it allows our team to set api inside personal project, and also describe several api paths.Listed here our experts just remove the design template of the ask for body, as well as send out the email passing the theme in the sendMail function of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body = wait for readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( bunch: process.env.HOST ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi globe',.html: body.template,..await transporter.sendMail( alternatives). ).If you are not making use of the web server in nuxt, you can conveniently carry out on any kind of platform as an example making use of show:.import convey from 'convey'.import nodemailer coming from 'nodemailer'.const app = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings world',.html: template,..wait for transporter.sendMail( alternatives).gain res.json( information: "Email sent" ). ).app.listen( 3001 ).Paperwork.Receive the total documents [here] ().Parts.You can easily find the elements, listed below:.Assimilations.Emails created with vue-email may be exchanged HTML or even.plain text, as well as sent out utilizing any kind of email service provider. You may see.instances listed here:.