panoramatrack-email-client 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # panoramatrack-email-client
package/index.js ADDED
@@ -0,0 +1,35 @@
1
+ //index.js
2
+ const nodemailer = require('nodemailer');
3
+
4
+ // Function to send an email
5
+ const sendEmail = async (mailConfig,to, subject, body) => {
6
+ try {
7
+ // Create a transporter with SMTP configuration
8
+ const transporter = nodemailer.createTransport({
9
+ host: mailConfig.host,
10
+ port: mailConfig.port,
11
+ secure: mailConfig.secure,
12
+ auth: {
13
+ user: mailConfig.user,
14
+ pass: mailConfig.pass,
15
+ },
16
+ });
17
+
18
+ // Define email options
19
+ const mailOptions = {
20
+ from: mailConfig.from,
21
+ to,
22
+ subject,
23
+ html: body,
24
+ };
25
+
26
+ // Send the email
27
+ const info = await transporter.sendMail(mailOptions);
28
+ console.log('Email sent:', info.messageId);
29
+ } catch (error) {
30
+ console.error('Error sending email:', error);
31
+ }
32
+ };
33
+ module.exports = {
34
+ sendEmail
35
+ };
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "panoramatrack-email-client",
3
+ "version": "1.0.0",
4
+ "description": "panoramatrack email client helper",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "Dolan Chowdhury",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "nodemailer": "^6.9.3"
13
+ }
14
+ }
package/test/index.js ADDED
@@ -0,0 +1,13 @@
1
+ const { sendEmail } = require('..');
2
+ console.log("Test Email");
3
+ // Usage example
4
+ mailConfig={
5
+ host: "",
6
+ port: 2525,
7
+ secure:false,
8
+ user: "",
9
+ pass: "",
10
+ };
11
+ sendEmail(mailConfig,'dd15@mailinator.com', 'Test Email', 'This is a test email.')
12
+ .then(() => console.log('Email sent successfully.'))
13
+ .catch((error) => console.error('Error sending email:', error));