Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually encouraged through react-email, it permits our team produce layouts using the vue structure, with components that assist us build themes easily and also quickly.To begin making use of vue-email in any sort of vue project, you simply require to mount the plan:.With NPM:.$ npm put in vue-email.With Yarn:.$ yarn incorporate vue-email.Along with PNPM:.$ pnpm put up vue-email.Generating e-mail design template.Develop a brand-new email theme in no matter where you would like to have your design templates, for this scenario, our company can easily make a layout directory, along with a theme gotten in touch with welcome.vue.src/templates/welcome. vue.

label, welcome to vue-email.A Vue component library for building receptive e-mails.Viewpoint on GitHub.Delighted coding!David Arenas.
Providing the themes.We may use the render functionality, it obtains two params, the 1st one is actually the layout to leave, and the 2nd the params to become used for the design template, and after that pass the end result template in the body system of demand.Passing the layout in the body, give our team the possibility of leaving making use of any kind of server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver email with nodemailer.Posted email.
Send e-mail.In this example i utilizing nuxt v3 since it permits us to specify api inside own project, and also determine several api routes.Right here our company only remove the template of the ask for body, and send out 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 body = wait for readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi globe',.html: body.template,..await transporter.sendMail( options). ).If you are actually not using the web server in nuxt, you can effortlessly execute on any framework for example utilizing reveal:.import share coming from 'share'.import nodemailer from 'nodemailer'.const app = express().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( host: process.env.HOST ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.target: 'greetings globe',.html: layout,..wait for transporter.sendMail( options).gain res.json( message: "Email delivered" ). ).app.listen( 3001 ).Documentation.Obtain the total paperwork [below] ().Elements.You can observe the components, listed here:.Combinations.E-mails built along with vue-email may be converted into HTML or.clear text, as well as delivered making use of any email service provider. You can easily find.examples right here:.

Articles You Can Be Interested In