0utmailcore 1.0.0
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 +47 -0
- package/package.json +13 -0
package/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// index.js
|
|
2
|
+
const API_URL = "https://api0utmail-test-email.vercel.app";
|
|
3
|
+
|
|
4
|
+
// Internal helper
|
|
5
|
+
const post = async (endpoint, payload) => {
|
|
6
|
+
try {
|
|
7
|
+
const res = await fetch(`${API_URL}${endpoint}`, {
|
|
8
|
+
method: "POST",
|
|
9
|
+
headers: { "Content-Type": "application/json" },
|
|
10
|
+
body: JSON.stringify(payload)
|
|
11
|
+
});
|
|
12
|
+
return await res.json();
|
|
13
|
+
} catch (err) {
|
|
14
|
+
return { success: false, error: err.message };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Send a plain text email.
|
|
20
|
+
* @param {string} apiKey - Your Firebase User Key
|
|
21
|
+
* @param {object} token - Your Google Token Object
|
|
22
|
+
* @param {string} to - Recipient Email
|
|
23
|
+
* @param {string} subject - Email Subject
|
|
24
|
+
* @param {string} text - Email Body
|
|
25
|
+
*/
|
|
26
|
+
exports.send = (apiKey, token, to, subject, text) =>
|
|
27
|
+
post("/send", { api_key: apiKey, google_token: token, to, subject, text });
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Send an HTML email.
|
|
31
|
+
* @param {string} apiKey - Your Firebase User Key
|
|
32
|
+
* @param {object} token - Your Google Token Object
|
|
33
|
+
* @param {string} to - Recipient Email
|
|
34
|
+
* @param {string} subject - Email Subject
|
|
35
|
+
* @param {string} html - HTML Body
|
|
36
|
+
*/
|
|
37
|
+
exports.sendHtml = (apiKey, token, to, subject, html) =>
|
|
38
|
+
post("/sendHtml", { api_key: apiKey, google_token: token, to, subject, html });
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Read the inbox.
|
|
42
|
+
* @param {string} apiKey - Your Firebase User Key
|
|
43
|
+
* @param {object} token - Your Google Token Object
|
|
44
|
+
* @param {number} limit - Number of emails (default 10)
|
|
45
|
+
*/
|
|
46
|
+
exports.read = (apiKey, token, limit = 10) =>
|
|
47
|
+
post("/read", { api_key: apiKey, google_token: token, limit });
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "0utmailcore",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The official 0utmail API client for Node.js",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "0xs4b",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"type": "commonjs"
|
|
13
|
+
}
|