Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually inspired by react-email, it permits our company make themes making use of the vue framework, with parts that aid our company build themes conveniently and swiftly.To begin utilizing vue-email in any kind of vue task, you only need to put in the package:.Along with NPM:.$ npm put in vue-email.Along with Anecdote:.$ anecdote include vue-email.Along with PNPM:.$ pnpm set up vue-email.Generating email template.Develop a brand new email template in wherever you want to have your layouts, for this instance, we can easily generate a layout folder, along with a design template called welcome.vue.src/templates/welcome. vue.

title, appreciated to vue-email.A Vue part public library for property receptive emails.Perspective on GitHub.Delighted coding!David Arenas.
Rendering the themes.Our team can easily use the render function, it receives 2 params, the initial one is the template to render, and the second the params to become utilized for the theme, and then pass the end result theme in the body system of demand.Passing the theme in the body, give our company the odds of leaving utilizing any sort of web server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email with nodemailer.Dispatched e-mail.
Send email.Within this example i making use of nuxt v3 given that it permits our team to establish api inside own venture, and also describe various api courses.Listed here our team only draw out the template of the ask for body, and deliver the e-mail passing the theme in the sendMail feature of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (event) =&gt const body system = wait for readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: false,.auth: individual: testAccount.user,.elapsed: testAccount.pass,.,. ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello globe',.html: body.template,..wait for transporter.sendMail( options). ).If you are certainly not making use of the web server in nuxt, you may effortlessly implement on any framework for example utilizing express:.bring express coming from 'share'.import nodemailer coming from 'nodemailer'.const application = reveal().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( 'smtp.ethereal.email',.slot: 587,.secure: inaccurate,.auth: individual: testAccount.user,.pass: testAccount.pass,.,. ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.target: 'greetings globe',.html: layout,..wait for transporter.sendMail( options).yield res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Information.Obtain the complete documentation [listed below] ().Elements.You can easily observe the components, listed here:.Assimilations.Emails developed with vue-email can be converted into HTML or.clear text, as well as sent out utilizing any type of e-mail company. You can easily view.examples listed below:.