Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually influenced through react-email, it enables us generate design templates using the vue platform, along with components that assist our team create layouts quickly as well as quick.To begin utilizing vue-email in any type of vue task, you simply need to put up the package:.Along with NPM:.$ npm mount vue-email.Along with Yarn:.$ anecdote add vue-email.Along with PNPM:.$ pnpm put up vue-email.Making e-mail design template.Make a brand-new e-mail design template in anywhere you intend to possess your layouts, for this instance, our team may generate a design template folder, with a design template gotten in touch with welcome.vue.src/templates/welcome. vue.

title, appreciated to vue-email.A Vue element collection for structure reactive e-mails.Perspective on GitHub.Satisfied coding!David Arenas.
Rendering the themes.Our company can use the leave feature, it obtains 2 params, the initial one is actually the theme to leave, and also the second the params to become made use of for the design template, and after that pass the outcome design template in the physical body of request.Passing the design template in the physical body, offer our team the chance of providing making use of any type of web server, show, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail along with nodemailer.Sent e-mail.
Deliver e-mail.Within this example i utilizing nuxt v3 because it permits our company to prepare api inside personal job, and specify various api options.Here our company simply extract the design template of the request physical body, and deliver the email passing the layout in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const physical body = await readBody( activity).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( multitude: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings world',.html: body.template,..await transporter.sendMail( possibilities). ).If you are actually not using the web server in nuxt, you can conveniently execute on any structure for instance utilizing convey:.import show from 'reveal'.import nodemailer coming from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( bunch: process.env.HOST ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello world',.html: layout,..await transporter.sendMail( choices).yield res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Documents.Obtain the total documents [here] ().Parts.You can easily observe the parts, listed below:.Assimilations.E-mails constructed along with vue-email could be converted into HTML or even.plain text, and also delivered using any type of email company. You can view.examples listed here:.