quick-mail
Advanced tools
Comparing version 1.0.9 to 1.0.10
51
index.js
@@ -1,15 +0,46 @@ | ||
const axios = require("axios"); | ||
const https = require("https"); | ||
async function sendEmail({ from, to, subject, text, password, html }) { | ||
try { | ||
const response = await axios.post( | ||
"https://us-central1-mail-npm.cloudfunctions.net/api/send-email", | ||
{ from, to, subject, text, password, html } | ||
); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error on sending mail'); | ||
} | ||
const postData = JSON.stringify({ from, to, subject, text, password, html }); | ||
const options = { | ||
hostname: "us-central1-mail-npm.cloudfunctions.net", | ||
path: "/api/send-email", | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Length": Buffer.byteLength(postData), | ||
}, | ||
}; | ||
return new Promise((resolve, reject) => { | ||
const req = https.request(options, (res) => { | ||
let data = ""; | ||
res.on("data", (chunk) => { | ||
data += chunk; | ||
}); | ||
res.on("end", () => { | ||
try { | ||
// Try to parse the response as JSON | ||
const jsonResponse = JSON.parse(data); | ||
resolve(jsonResponse); | ||
} catch (e) { | ||
// If parsing fails, resolve with the plain text response | ||
resolve(data); | ||
} | ||
}); | ||
}); | ||
req.on("error", (e) => { | ||
console.error("Error on sending mail", e); | ||
reject(e); | ||
}); | ||
req.write(postData); | ||
req.end(); | ||
}); | ||
} | ||
module.exports = { sendEmail }; |
{ | ||
"name": "quick-mail", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "quick-mail is a powerful and flexible email automation library designed for JavaScript applications. It enables developers to easily send bulk emails with variant subjects and content using different or customized HTML templates. This library simplifies the process of managing and automating email campaigns, making it ideal for marketing, notifications, and other automated email tasks.", | ||
@@ -11,3 +11,2 @@ "main": "index.js", | ||
"dependencies": { | ||
"axios": "^1.7.2" | ||
}, | ||
@@ -14,0 +13,0 @@ "keywords": [ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
5838
0
38
1
- Removedaxios@^1.7.2
- Removedasynckit@0.4.0(transitive)
- Removedaxios@1.7.9(transitive)
- Removedcall-bind-apply-helpers@1.0.2(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedes-set-tostringtag@2.1.0(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedform-data@4.0.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedproxy-from-env@1.1.0(transitive)