We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0200d23 commit fe5baaaCopy full SHA for fe5baaa
server/Controllers/LeaveController.js
@@ -1,6 +1,7 @@
1
const User = require('../Models/User')
2
const Leave = require('../Models/Leave')
3
const nodemailer = require('nodemailer');
4
+const Email = require('../Models/Email')
5
6
const transporter = nodemailer.createTransport({
7
service: 'gmail',
@@ -60,7 +61,14 @@ const LeaveController = {
60
61
subject: "Notifications from ERP",
62
text: "There is a new Leave to Approve from" + reqEmail,
63
};
- // return res.json({ Status: "Success"})
64
+ try {
65
+ await transporter.sendMail(mailOptions);
66
+ const email = new Email({ to, subject, body });
67
+ await email.save();
68
+ return res.json({ Status: "Success"})
69
+ } catch (error) {
70
+ return res.json({ Error: "Error While Sending Emails"})
71
+ }
72
73
}
74
else{
0 commit comments