Sleep

Vue- Email - Vue.js Nourished

.Vue-email is motivated through react-email, it enables our team generate templates utilizing the vue framework, with components that aid us develop design templates quickly as well as quickly.To start using vue-email in any sort of vue task, you simply require to install the package:.With NPM:.$ npm mount vue-email.Along with Yarn:.$ anecdote add vue-email.Along with PNPM:.$ pnpm set up vue-email.Creating e-mail layout.Develop a brand new email layout in wherever you intend to have your layouts, for this instance, our company can easily produce a template folder, along with a layout contacted welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue part library for building responsive emails.Sight on GitHub.Satisfied coding!David Arenas.
Making the templates.Our team can easily utilize the render feature, it receives pair of params, the initial one is actually the layout to make, and also the second the params to be used for the layout, and after that pass the result template in the body of ask for.Passing the template in the body system, give our team the opportunity of providing making use of any type of web server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send e-mail with nodemailer.Emailed email.
Send email.In this particular example i using nuxt v3 considering that it allows us to set api inside very own job, and also determine a number of api options.Right here our company just remove the layout of the request body, as well as send the e-mail passing the layout in the sendMail function of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body = wait for readBody( event).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.protected: false,.auth: customer: testAccount.user,.pass: testAccount.pass,.,. ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi globe',.html: body.template,..await transporter.sendMail( choices). ).If you are actually not making use of the web server in nuxt, you may conveniently carry out on any type of framework as an example using share:.bring share coming from 'reveal'.import nodemailer coming from 'nodemailer'.const app = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.secure: inaccurate,.auth: individual: testAccount.user,.elapsed: testAccount.pass,.,. ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello there globe',.html: template,..wait for transporter.sendMail( alternatives).profit res.json( information: "Email sent" ). ).app.listen( 3001 ).Documents.Obtain the complete paperwork [listed here] ().Components.You may see the parts, listed below:.Combinations.Emails built along with vue-email can be converted into HTML or even.plain text, as well as sent using any email company. You can find.instances listed below:.