panoramatrack-email-client 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +16 -7
- package/package.json +1 -1
- package/test/index.js +1 -1
package/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
const nodemailer = require('nodemailer');
|
|
3
3
|
|
|
4
4
|
// Function to send an email
|
|
5
|
-
const sendEmail = async (mailConfig,
|
|
5
|
+
const sendEmail = async (mailConfig,Options) => {
|
|
6
|
+
const response={};
|
|
6
7
|
try {
|
|
7
8
|
// Create a transporter with SMTP configuration
|
|
8
9
|
const transporter = nodemailer.createTransport({
|
|
@@ -17,17 +18,25 @@ const sendEmail = async (mailConfig,to, subject, body) => {
|
|
|
17
18
|
|
|
18
19
|
// Define email options
|
|
19
20
|
const mailOptions = {
|
|
20
|
-
from:
|
|
21
|
-
to,
|
|
22
|
-
subject,
|
|
23
|
-
html:
|
|
21
|
+
from: Options.from,
|
|
22
|
+
to:Options.to,
|
|
23
|
+
subject:Options.subject,
|
|
24
|
+
html: Options.html,
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
// Send the email
|
|
28
|
+
// console.log('Email sent:', info.messageId);
|
|
27
29
|
const info = await transporter.sendMail(mailOptions);
|
|
28
|
-
|
|
30
|
+
response.status_code =200;
|
|
31
|
+
response.status =true;
|
|
32
|
+
response.messageId = info.messageId;
|
|
33
|
+
return response;
|
|
29
34
|
} catch (error) {
|
|
30
|
-
console.error('Error sending email:', error);
|
|
35
|
+
// console.error('Error sending email:', error);
|
|
36
|
+
response.status_code =500;
|
|
37
|
+
response.status =false;
|
|
38
|
+
response.error =error;
|
|
39
|
+
return response;
|
|
31
40
|
}
|
|
32
41
|
};
|
|
33
42
|
module.exports = {
|
package/package.json
CHANGED
package/test/index.js
CHANGED
|
@@ -8,6 +8,6 @@ mailConfig={
|
|
|
8
8
|
user: "",
|
|
9
9
|
pass: "",
|
|
10
10
|
};
|
|
11
|
-
sendEmail(mailConfig,'
|
|
11
|
+
sendEmail(mailConfig,'test@mailinator.com', 'Test Email', 'This is a test email.')
|
|
12
12
|
.then(() => console.log('Email sent successfully.'))
|
|
13
13
|
.catch((error) => console.error('Error sending email:', error));
|