Skip to content

Commit

Permalink
SIKKA-4956[IN PROGRESS]
Browse files Browse the repository at this point in the history
  • Loading branch information
Mansourkira committed Oct 6, 2023
1 parent bafdf2c commit 7aa249d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sikka/hajar",
"version": "1.1.16",
"version": "1.1.17",
"description": "Toolkit to create SaaS applications",
"author": "Sikka Software <[email protected]> (http://sikka.io)",
"license": "MIT",
Expand Down
27 changes: 17 additions & 10 deletions src/core/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,24 @@ class HajarMail {

return transporter;
}
async sendEmail({ emailConfig, template, ...data }) {
// Use the emailConfig to setup the transporter
let transporter = this.nodemailer.createTransport(emailConfig);
async sendEmail({ emailConfig, resetPasswordEmailTemplate, ...emailData }) {
try {
// Use the emailConfig to setup the transporter
let transporter = this.nodemailer.createTransport(emailConfig);

// Use the emailConfig and html to send the email
await transporter.sendMail({
from: emailConfig.auth.user,
to: data.to,
subject: data.subject,
html: template(data),
});
// Use the emailConfig and resetPasswordEmailTemplate to send the email
await transporter.sendMail({
from: emailConfig.auth.user,
to: emailData.to,
subject: emailData.subject,
html: resetPasswordEmailTemplate,
});

console.log("Email sent successfully");
} catch (err) {
console.error(err);
throw err; // Rethrow the error for handling in your route handler
}
}

/*
Expand Down

0 comments on commit 7aa249d

Please sign in to comment.