Sleep

Vue- Email - Vue.js Nourished

.Vue-email is encouraged by react-email, it enables us produce templates making use of the vue platform, with parts that help our team build design templates conveniently as well as quickly.To start making use of vue-email in any vue job, you just need to have to mount the package deal:.With NPM:.$ npm put in vue-email.Along with Anecdote:.$ anecdote add vue-email.Along with PNPM:.$ pnpm mount vue-email.Creating e-mail layout.Develop a brand new email design template in no matter where you want to possess your design templates, for this scenario, our team may develop a theme directory, with a theme gotten in touch with welcome.vue.src/templates/welcome. vue.

label, invited to vue-email.A Vue element public library for structure responsive e-mails.Sight on GitHub.Pleased coding!David Arenas.
Providing the templates.Our team can utilize the leave function, it gets pair of params, the very first one is actually the design template to render, and also the 2nd the params to be utilized for the layout, and then pass the end result template in the body of demand.Passing the template in the physical body, offer our team the odds of providing utilizing any type of server, show, fastify, nuxt in SSR, and so on src/pages/index. vue.Send email along with nodemailer.Mailed e-mail.
Deliver email.In this example i utilizing nuxt v3 due to the fact that it allows our company to set api inside very own job, and also define several api routes.Here our team merely remove the template of the demand body, and also send the e-mail passing the layout in the sendMail feature of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const physical body = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const options = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello globe',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually certainly not utilizing the server in nuxt, you may conveniently apply on any type of framework for instance utilizing show:.bring reveal 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 template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe: inaccurate,.auth: customer: testAccount.user,.elapsed: testAccount.pass,.,. ).const options = from: 'you@example.com',.to: 'user@gmail.com',.target: 'greetings world',.html: theme,..await transporter.sendMail( alternatives).return res.json( message: "Email sent" ). ).app.listen( 3001 ).Documents.Get the total information [listed here] ().Components.You can easily see the elements, listed below:.Combinations.Emails built along with vue-email can be exchanged HTML or even.plain text, as well as delivered using any sort of email specialist. You may observe.instances right here:.