Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually motivated by react-email, it permits our team create themes making use of the vue structure, with elements that help us build templates effortlessly as well as quick.To begin using vue-email in any type of vue project, you merely need to put in the package deal:.Along with NPM:.$ npm mount vue-email.Along with Yarn:.$ yarn add vue-email.Along with PNPM:.$ pnpm set up vue-email.Creating e-mail design template.Make a brand-new email theme in anywhere you want to have your themes, for this case, our team can make a template directory, with a design template contacted welcome.vue.src/templates/welcome. vue.

title, invited to vue-email.A Vue part public library for property receptive emails.View on GitHub.Pleased coding!David Arenas.
Leaving the themes.We can easily make use of the provide functionality, it receives 2 params, the very first one is the design template to leave, and also the second the params to be used for the layout, and then pass the outcome theme in the body system of ask for.Passing the theme in the body, give our team the odds of making utilizing any kind of hosting server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email with nodemailer.Mailed e-mail.
Send out email.In this particular instance i making use of nuxt v3 due to the fact that it enables our team to establish api inside own project, as well as specify various api routes.Below our team merely extract the template of the request physical body, and also send out the e-mail passing the design template in the sendMail feature of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body system = await readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( multitude: process.env.HOST ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi there planet',.html: body.template,..wait for transporter.sendMail( alternatives). ).If you are not utilizing the server in nuxt, you can quickly carry out on any sort of platform as an example making use of share:.import share coming from 'show'.bring in nodemailer from 'nodemailer'.const app = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.protected: untrue,.auth: consumer: testAccount.user,.pass: testAccount.pass,.,. ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings world',.html: layout,..wait for transporter.sendMail( options).return res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Records.Obtain the full documents [below] ().Parts.You can view the components, listed below:.Assimilations.E-mails built along with vue-email could be converted into HTML or.plain text, and sent out utilizing any type of e-mail company. You can easily view.examples below:.

Articles You Can Be Interested In