Skip to content

Commit

Permalink
Update mailHelper.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed May 3, 2024
1 parent ce384ea commit 5c9341e
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions api/src/common/mailHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ import * as env from '../config/env.config'
* @param {nodemailer.SendMailOptions} mailOptions
* @returns {Promise<unknown>}
*/
export const sendMail = (mailOptions: nodemailer.SendMailOptions) => {
const transporterOptions: SMTPTransport.Options = {
host: env.SMTP_HOST,
port: env.SMTP_PORT,
auth: {
user: env.SMTP_USER,
pass: env.SMTP_PASS,
},
}
export const sendMail = (mailOptions: nodemailer.SendMailOptions): Promise<nodemailer.SentMessageInfo> => {
const transporterOptions: SMTPTransport.Options = {
host: env.SMTP_HOST,
port: env.SMTP_PORT,
auth: {
user: env.SMTP_USER,
pass: env.SMTP_PASS,
},
}

const transporter: nodemailer.Transporter = nodemailer.createTransport(transporterOptions)
const transporter: nodemailer.Transporter = nodemailer.createTransport(transporterOptions)

return new Promise((resolve, reject) => {
transporter.sendMail(mailOptions, (err: Error | null, info: nodemailer.SentMessageInfo) => {
if (err) {
reject(err)
} else {
resolve(info)
}
})
return new Promise((resolve, reject) => {
transporter.sendMail(mailOptions, (err: Error | null, info: nodemailer.SentMessageInfo) => {
if (err) {
reject(err)
} else {
resolve(info)
}
})
})
}

0 comments on commit 5c9341e

Please sign in to comment.