mailcub 2.0.10 → 2.0.12

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.
Files changed (2) hide show
  1. package/README.md +179 -179
  2. package/package.json +9 -6
package/README.md CHANGED
@@ -1,179 +1,179 @@
1
- # Mailcub — Send email from Node.js with your domain
2
-
3
- **Mailcub** is a Node.js npm package to send HTML or plain-text emails and attachments using your registered domain. Simple API, secret-key auth, ideal for transactional email and newsletters.
4
-
5
- [![npm version](https://img.shields.io/npm/v/mailcub.svg)](https://www.npmjs.com/package/mailcub)
6
- [![npm downloads](https://img.shields.io/npm/dm/mailcub.svg)](https://www.npmjs.com/package/mailcub)
7
- [![license](https://img.shields.io/npm/l/mailcub.svg)](https://www.npmjs.com/package/mailcub)
8
-
9
- ---
10
-
11
- ## Installation
12
-
13
- ```bash
14
- npm install mailcub
15
- ```
16
-
17
- ---
18
-
19
- ## Quick example (30-second demo)
20
-
21
- ```javascript
22
- const mailcub = require('mailcub');
23
-
24
- const emailBody = {
25
- email_from: 'hello@yourdomain.com',
26
- receiver: 'user@example.com',
27
- subject: 'Welcome',
28
- html: '<h1>Hello!</h1><p>Thanks for signing up.</p>'
29
- };
30
-
31
- mailcub.sendMail(emailBody, 'your-secret-key')
32
- .then(() => console.log('Email sent'))
33
- .catch(err => console.error('Error:', err));
34
- ```
35
-
36
- Get your secret key at [client.mailcub.com](https://client.mailcub.com).
37
-
38
- ---
39
-
40
- ## Full API & options
41
-
42
- ### `sendMail(body, key)`
43
-
44
- Sends an email. Returns a Promise.
45
-
46
- | Parameter | Type | Description |
47
- |-----------|------|-------------|
48
- | `body` | Object | Email payload (see below). |
49
- | `key` | String | Secret key for authentication. From [client.mailcub.com](https://client.mailcub.com). |
50
-
51
- ### `body` object
52
-
53
- | Field | Type | Required | Description |
54
- |-------|------|----------|-------------|
55
- | `email_from` | string | Yes | Sender email (use an address on your registered domain). |
56
- | `receiver` | string | Yes | Recipient email address. |
57
- | `subject` | string | Yes | Email subject line. |
58
- | `html` | string | No* | HTML body of the email. |
59
- | `text` | string | No* | Plain-text body of the email. Use `html` or `text` (or both). |
60
- | `attachment` | File or File[] | No | Single file or array of files (file objects only, not paths). |
61
-
62
- *At least one of `html` or `text` is required.
63
-
64
- ### Examples
65
-
66
- **Plain text only**
67
-
68
- ```javascript
69
- mailcub.sendMail({
70
- email_from: 'noreply@yourdomain.com',
71
- receiver: 'customer@example.com',
72
- subject: 'Order confirmation',
73
- text: 'Thank you for your order. Order #1234 has been received.'
74
- }, process.env.MAILCUB_SECRET_KEY);
75
- ```
76
-
77
- **HTML only**
78
-
79
- ```javascript
80
- mailcub.sendMail({
81
- email_from: 'noreply@yourdomain.com',
82
- receiver: 'customer@example.com',
83
- subject: 'Order confirmation',
84
- html: '<h1>Order #1234</h1><p>Thank you for your order.</p>'
85
- }, process.env.MAILCUB_SECRET_KEY);
86
- ```
87
-
88
- **With a single attachment**
89
-
90
- ```javascript
91
- // attachment = file from request, Postman, etc.
92
- mailcub.sendMail({
93
- email_from: 'billing@yourdomain.com',
94
- receiver: 'client@example.com',
95
- subject: 'Your invoice',
96
- html: '<p>Please find your invoice attached.</p>',
97
- attachment
98
- }, process.env.MAILCUB_SECRET_KEY);
99
- ```
100
-
101
- **With multiple attachments**
102
-
103
- ```javascript
104
- // attachment = array of files (e.g. from request, Postman, etc.)
105
- mailcub.sendMail({
106
- email_from: 'team@yourdomain.com',
107
- receiver: 'user@example.com',
108
- subject: 'Your documents',
109
- html: '<p>Attached are the requested files.</p>',
110
- attachment: [file1, file2]
111
- }, process.env.MAILCUB_SECRET_KEY);
112
- ```
113
-
114
- **Using async/await**
115
-
116
- ```javascript
117
- const mailcub = require('mailcub');
118
-
119
- async function sendWelcomeEmail(to) {
120
- try {
121
- await mailcub.sendMail({
122
- email_from: 'hello@yourdomain.com',
123
- receiver: to,
124
- subject: 'Welcome',
125
- html: '<h1>Welcome!</h1>'
126
- }, process.env.MAILCUB_SECRET_KEY);
127
- return true;
128
- } catch (err) {
129
- console.error(err);
130
- return false;
131
- }
132
- }
133
- ```
134
-
135
- ---
136
-
137
- ## Why choose Mailcub?
138
-
139
- - **Simple API** — One function, clear parameters; no SMTP or server config.
140
- - **Your domain** — Send from your own domain for a professional, branded look.
141
- - **HTML or plain text** — Send rich HTML or simple plain-text emails (or both).
142
- - **Attachments** — Single or multiple file attachments.
143
- - **Secret-key auth** — Secure authentication; keep your key in env vars.
144
- - **Lightweight** — Minimal dependencies; fits into existing Node.js apps.
145
- - **Transactional & newsletters** — Suited for both one-off emails and bulk sending.
146
-
147
- ---
148
-
149
- ## Troubleshooting & FAQ
150
-
151
- **Where do I get the secret key?**
152
- Sign up and get your key at [client.mailcub.com](https://client.mailcub.com).
153
-
154
- **"Error sending email" or failed requests**
155
- - Ensure `email_from` uses a domain you’ve registered in Mailcub.
156
- - Check that your secret key is correct and not expired.
157
- - Verify `receiver` and `subject` are non-empty; include at least one of `html` or `text`.
158
-
159
- **Attachments not sending**
160
- - `attachment` must be file(s) (e.g. from request, Postman, or your app), not path strings.
161
- - For multiple files, pass an array: `attachment: [file1, file2]`.
162
-
163
- **Need help?**
164
- Contact **support@mailcub.com** or open an issue: [GitHub Issues](https://github.com/devflips/mailcub/issues).
165
-
166
- ---
167
-
168
- ## Contributing & Code of Conduct
169
-
170
- Contributions are welcome. Please open an issue or pull request on [GitHub](https://github.com/devflips/mailcub). Be respectful and constructive; we expect a courteous, inclusive environment for everyone.
171
-
172
- ---
173
-
174
-
175
- ## License & Author
176
-
177
- - **License:** [ISC](https://opensource.org/licenses/ISC)
178
- - **Author:** [Devflips](https://github.com/devflips)
179
- - **Package:** [npm — mailcub](https://www.npmjs.com/package/mailcub) · [GitHub — mailcub](https://github.com/devflips/mailcub)
1
+ # Mailcub — Node.js SDK to send transactional emails and newsletters from your own domain using the MailCub email API.
2
+
3
+ **Mailcub** is a lightweight Node.js package for sending HTML or plaintext emails and attachments from your own domain via the MailCub email API. It’s built for transactional emails, app notifications, and simple newsletters without managing SMTP servers yourself.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/mailcub.svg)](https://www.npmjs.com/package/mailcub)
6
+ [![npm downloads](https://img.shields.io/npm/dm/mailcub.svg)](https://www.npmjs.com/package/mailcub)
7
+ [![license](https://img.shields.io/npm/l/mailcub.svg)](https://www.npmjs.com/package/mailcub)
8
+
9
+ ---
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install mailcub
15
+ ```
16
+
17
+ ---
18
+
19
+ ## Quick example (30-second demo)
20
+
21
+ ```javascript
22
+ const mailcub = require('mailcub');
23
+
24
+ const emailBody = {
25
+ email_from: 'hello@yourdomain.com',
26
+ receiver: 'user@example.com',
27
+ subject: 'Welcome',
28
+ html: '<h1>Hello!</h1><p>Thanks for signing up.</p>'
29
+ };
30
+
31
+ mailcub.sendMail(emailBody, 'your-secret-key')
32
+ .then(() => console.log('Email sent'))
33
+ .catch(err => console.error('Error:', err));
34
+ ```
35
+
36
+ Get your secret key at [mailcub.com](https://mailcub.com).
37
+
38
+ ---
39
+
40
+ ## Full API & options
41
+
42
+ ### `sendMail(body, key)`
43
+
44
+ Sends an email. Returns a Promise.
45
+
46
+ | Parameter | Type | Description |
47
+ |-----------|------|-------------|
48
+ | `body` | Object | Email payload (see below). |
49
+ | `key` | String | Secret key for authentication. From [client.mailcub.com](https://client.mailcub.com). |
50
+
51
+ ### `body` object
52
+
53
+ | Field | Type | Required | Description |
54
+ |-------|------|----------|-------------|
55
+ | `email_from` | string | Yes | Sender email (use an address on your registered domain). |
56
+ | `receiver` | string | Yes | Recipient email address. |
57
+ | `subject` | string | Yes | Email subject line. |
58
+ | `html` | string | No* | HTML body of the email. |
59
+ | `text` | string | No* | Plain-text body of the email. Use `html` or `text` (or both). |
60
+ | `attachment` | File or File[] | No | Single file or array of files (file objects only, not paths). |
61
+
62
+ *At least one of `html` or `text` is required.
63
+
64
+ ### Examples
65
+
66
+ **Plain text only**
67
+
68
+ ```javascript
69
+ mailcub.sendMail({
70
+ email_from: 'noreply@yourdomain.com',
71
+ receiver: 'customer@example.com',
72
+ subject: 'Order confirmation',
73
+ text: 'Thank you for your order. Order #1234 has been received.'
74
+ }, process.env.MAILCUB_SECRET_KEY);
75
+ ```
76
+
77
+ **HTML only**
78
+
79
+ ```javascript
80
+ mailcub.sendMail({
81
+ email_from: 'noreply@yourdomain.com',
82
+ receiver: 'customer@example.com',
83
+ subject: 'Order confirmation',
84
+ html: '<h1>Order #1234</h1><p>Thank you for your order.</p>'
85
+ }, process.env.MAILCUB_SECRET_KEY);
86
+ ```
87
+
88
+ **With a single attachment**
89
+
90
+ ```javascript
91
+ // attachment = file from request, Postman, etc.
92
+ mailcub.sendMail({
93
+ email_from: 'billing@yourdomain.com',
94
+ receiver: 'client@example.com',
95
+ subject: 'Your invoice',
96
+ html: '<p>Please find your invoice attached.</p>',
97
+ attachment
98
+ }, process.env.MAILCUB_SECRET_KEY);
99
+ ```
100
+
101
+ **With multiple attachments**
102
+
103
+ ```javascript
104
+ // attachment = array of files (e.g. from request, Postman, etc.)
105
+ mailcub.sendMail({
106
+ email_from: 'team@yourdomain.com',
107
+ receiver: 'user@example.com',
108
+ subject: 'Your documents',
109
+ html: '<p>Attached are the requested files.</p>',
110
+ attachment: [file1, file2]
111
+ }, process.env.MAILCUB_SECRET_KEY);
112
+ ```
113
+
114
+ **Using async/await**
115
+
116
+ ```javascript
117
+ const mailcub = require('mailcub');
118
+
119
+ async function sendWelcomeEmail(to) {
120
+ try {
121
+ await mailcub.sendMail({
122
+ email_from: 'hello@yourdomain.com',
123
+ receiver: to,
124
+ subject: 'Welcome',
125
+ html: '<h1>Welcome!</h1>'
126
+ }, process.env.MAILCUB_SECRET_KEY);
127
+ return true;
128
+ } catch (err) {
129
+ console.error(err);
130
+ return false;
131
+ }
132
+ }
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Why choose Mailcub?
138
+
139
+ - **Simple API** — One function, clear parameters; no SMTP or server config.
140
+ - **Your domain** — Send from your own domain for a professional, branded look.
141
+ - **HTML or plain text** — Send rich HTML or simple plain-text emails (or both).
142
+ - **Attachments** — Single or multiple file attachments.
143
+ - **Secret-key auth** — Secure authentication; keep your key in env vars.
144
+ - **Lightweight** — Minimal dependencies; fits into existing Node.js apps.
145
+ - **Transactional & newsletters** — Suited for both one-off emails and bulk sending.
146
+
147
+ ---
148
+
149
+ ## Troubleshooting & FAQ
150
+
151
+ **Where do I get the secret key?**
152
+ Sign up and get your key at [client.mailcub.com](https://client.mailcub.com).
153
+
154
+ **"Error sending email" or failed requests**
155
+ - Ensure `email_from` uses a domain you’ve registered in Mailcub.
156
+ - Check that your secret key is correct and not expired.
157
+ - Verify `receiver` and `subject` are non-empty; include at least one of `html` or `text`.
158
+
159
+ **Attachments not sending**
160
+ - `attachment` must be file(s) (e.g. from request, Postman, or your app), not path strings.
161
+ - For multiple files, pass an array: `attachment: [file1, file2]`.
162
+
163
+ **Need help?**
164
+ Contact **support@mailcub.com** or open an issue: [GitHub Issues](https://github.com/devflips/mailcub/issues).
165
+
166
+ ---
167
+
168
+ ## Contributing & Code of Conduct
169
+
170
+ Contributions are welcome. Please open an issue or pull request on [GitHub](https://github.com/devflips/mailcub). Be respectful and constructive; we expect a courteous, inclusive environment for everyone.
171
+
172
+ ---
173
+
174
+
175
+ ## License & Author
176
+
177
+ - **License:** [ISC](https://opensource.org/licenses/ISC)
178
+ - **Author:** [Devflips](https://github.com/devflips)
179
+ - **Package:** [npm — mailcub](https://www.npmjs.com/package/mailcub) · [GitHub — mailcub](https://github.com/devflips/mailcub)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailcub",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "This package enables users to send emails using their registered domains, providing a professional and branded approach to communication.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,11 +17,14 @@
17
17
  "author": "Devflips",
18
18
  "license": "ISC",
19
19
  "keywords": [
20
- "mailcub",
21
- "mailcub api",
22
- "email",
23
- "mail",
24
- "newsletter"
20
+ "mailcub",
21
+ "email",
22
+ "email api",
23
+ "transactional email",
24
+ "smtp",
25
+ "nodejs",
26
+ "email hosting",
27
+ "mail server"
25
28
  ],
26
29
  "bugs": {
27
30
  "url": "https://github.com/devflips/mailcub/issues"