Sleep

Vue- Email - Vue.js Nourished

.Vue-email is inspired through react-email, it allows us make design templates making use of the vue framework, with elements that help our team build themes conveniently and also fast.To start utilizing vue-email in any type of vue project, you merely need to have to mount the deal:.Along with NPM:.$ npm put up vue-email.Along with Yarn:.$ yarn add vue-email.Along with PNPM:.$ pnpm put up vue-email.Creating email theme.Make a brand-new e-mail design template in wherever you intend to have your templates, for this case, our team can create a template file, along with a theme gotten in touch with welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue element collection for building reactive e-mails.Viewpoint on GitHub.Delighted coding!David Arenas.
Leaving the layouts.We can utilize the provide functionality, it gets pair of params, the very first one is the layout to leave, and the second the params to be used for the design template, and then pass the end result design template in the body of request.Passing the template in the body system, give us the odds of leaving using any type of hosting server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Send out email along with nodemailer.Dispatched e-mail.
Send e-mail.Within this instance i making use of nuxt v3 since it enables us to set api inside own venture, and also specify numerous api routes.Listed below our team simply remove the design template of the request body, and also send the email passing the theme in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body = await readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( host: process.env.HOST ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello there planet',.html: body.template,..wait for transporter.sendMail( options). ).If you are actually certainly not making use of the server in nuxt, you can effortlessly carry out on any sort of framework for example using convey:.bring reveal from 'share'.bring in nodemailer coming from 'nodemailer'.const application = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there planet',.html: theme,..wait for transporter.sendMail( options).profit res.json( information: "Email sent out" ). ).app.listen( 3001 ).Documents.Acquire the complete information [right here] ().Parts.You may see the components, listed below:.Integrations.E-mails built with vue-email may be converted into HTML or.clear text, as well as sent using any type of email specialist. You may find.examples right here:.