Sleep

Vue- Email - Vue.js Feed

.Vue-email is influenced by react-email, it allows us develop themes utilizing the vue platform, with parts that help our team construct design templates easily and quick.To begin using vue-email in any vue project, you just need to put in the plan:.Along with NPM:.$ npm set up vue-email.Along with Yarn:.$ yarn add vue-email.Along with PNPM:.$ pnpm install vue-email.Developing email theme.Develop a new e-mail template in no matter where you desire to have your templates, for this case, our experts may make a design template file, with a layout called welcome.vue.src/templates/welcome. vue.

title, appreciated to vue-email.A Vue part library for building receptive e-mails.Viewpoint on GitHub.Delighted coding!David Arenas.
Rendering the layouts.Our team can use the leave functionality, it receives 2 params, the first one is actually the layout to render, and also the 2nd the params to become utilized for the theme, and after that pass the result template in the body system of ask for.Passing the template in the body, give us the possibility of rendering using any type of hosting server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Send email with nodemailer.Routed email.
Deliver e-mail.In this particular example i making use of nuxt v3 considering that it allows our team to specify api inside personal project, and describe various api courses.Right here our experts only extract the theme of the ask for body system, and send out the e-mail passing the design template in the sendMail functionality of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const physical body = await readBody( occasion).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe and secure: inaccurate,.auth: individual: testAccount.user,.pass: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hey there globe',.html: body.template,..await transporter.sendMail( options). ).If you are not using the web server in nuxt, you may simply execute on any platform for example utilizing express:.bring express coming from 'convey'.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( 'smtp.ethereal.email',.slot: 587,.protected: false,.auth: consumer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi planet',.html: theme,..wait for transporter.sendMail( alternatives).return res.json( information: "Email sent" ). ).app.listen( 3001 ).Documents.Obtain the full records [here] ().Parts.You can observe the components, listed here:.Integrations.E-mails created along with vue-email may be converted into HTML or even.plain text, as well as sent out utilizing any email provider. You can easily see.instances here:.