emailjs 4.0.3 โ†’ 5.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.
Files changed (84) hide show
  1. package/README.md +215 -247
  2. package/dist/address.d.ts +6 -0
  3. package/dist/address.js +183 -0
  4. package/dist/address.js.map +1 -0
  5. package/dist/address.test.d.ts +1 -0
  6. package/dist/address.test.js +120 -0
  7. package/dist/address.test.js.map +1 -0
  8. package/dist/auth.integration.test.d.ts +1 -0
  9. package/dist/auth.integration.test.js +137 -0
  10. package/dist/auth.integration.test.js.map +1 -0
  11. package/dist/client.d.ts +39 -0
  12. package/dist/client.integration.test.d.ts +1 -0
  13. package/dist/client.integration.test.js +198 -0
  14. package/dist/client.integration.test.js.map +1 -0
  15. package/dist/client.js +196 -0
  16. package/dist/client.js.map +1 -0
  17. package/dist/client.test.d.ts +1 -0
  18. package/dist/client.test.js +260 -0
  19. package/dist/client.test.js.map +1 -0
  20. package/dist/connection.commands.integration.test.d.ts +1 -0
  21. package/dist/connection.commands.integration.test.js +79 -0
  22. package/dist/connection.commands.integration.test.js.map +1 -0
  23. package/dist/connection.d.ts +83 -0
  24. package/dist/connection.errors.integration.test.d.ts +1 -0
  25. package/dist/connection.errors.integration.test.js +186 -0
  26. package/dist/connection.errors.integration.test.js.map +1 -0
  27. package/dist/connection.greylist.integration.test.d.ts +1 -0
  28. package/dist/connection.greylist.integration.test.js +53 -0
  29. package/dist/connection.greylist.integration.test.js.map +1 -0
  30. package/dist/connection.integration.test.d.ts +1 -0
  31. package/dist/connection.integration.test.js +223 -0
  32. package/dist/connection.integration.test.js.map +1 -0
  33. package/dist/connection.js +491 -0
  34. package/dist/connection.js.map +1 -0
  35. package/dist/connection.test.d.ts +1 -0
  36. package/dist/connection.test.js +50 -0
  37. package/dist/connection.test.js.map +1 -0
  38. package/dist/date.d.ts +3 -0
  39. package/dist/date.js +26 -0
  40. package/dist/date.js.map +1 -0
  41. package/dist/date.test.d.ts +1 -0
  42. package/dist/date.test.js +26 -0
  43. package/dist/date.test.js.map +1 -0
  44. package/dist/error.d.ts +20 -0
  45. package/dist/error.js +31 -0
  46. package/dist/error.js.map +1 -0
  47. package/dist/error.test.d.ts +1 -0
  48. package/dist/error.test.js +23 -0
  49. package/dist/error.test.js.map +1 -0
  50. package/dist/index.d.ts +8 -0
  51. package/dist/index.js +9 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/message.d.ts +71 -0
  54. package/dist/message.integration.test.d.ts +1 -0
  55. package/dist/message.integration.test.js +401 -0
  56. package/dist/message.integration.test.js.map +1 -0
  57. package/dist/message.js +456 -0
  58. package/dist/message.js.map +1 -0
  59. package/dist/message.test.d.ts +1 -0
  60. package/dist/message.test.js +258 -0
  61. package/dist/message.test.js.map +1 -0
  62. package/dist/mime.d.ts +2 -0
  63. package/dist/mime.js +145 -0
  64. package/dist/mime.js.map +1 -0
  65. package/dist/mime.test.d.ts +1 -0
  66. package/dist/mime.test.js +76 -0
  67. package/dist/mime.test.js.map +1 -0
  68. package/dist/response.d.ts +6 -0
  69. package/dist/response.js +93 -0
  70. package/dist/response.js.map +1 -0
  71. package/dist/response.test.d.ts +1 -0
  72. package/dist/response.test.js +177 -0
  73. package/dist/response.test.js.map +1 -0
  74. package/package.json +30 -28
  75. package/email.js +0 -2126
  76. package/email.ts +0 -8
  77. package/smtp/address.ts +0 -237
  78. package/smtp/client.ts +0 -365
  79. package/smtp/connection.ts +0 -937
  80. package/smtp/date.ts +0 -51
  81. package/smtp/error.ts +0 -57
  82. package/smtp/message.ts +0 -774
  83. package/smtp/mime.ts +0 -234
  84. package/smtp/response.ts +0 -112
package/README.md CHANGED
@@ -1,320 +1,288 @@
1
- # emailjs [![Test Status](https://github.com/eleith/emailjs/workflows/.github/workflows/test.yml/badge.svg)](https://github.com/eleith/emailjs/actions?query=workflow%3A.github%2Fworkflows%2Ftest.yml) [![Lint Status](https://github.com/eleith/emailjs/workflows/.github/workflows/lint.yml/badge.svg)](https://github.com/eleith/emailjs/actions?query=workflow%3A.github%2Fworkflows%2Flint.yml)
1
+ # emailjs ๐Ÿ“งโœจ
2
2
 
3
- send emails, html and attachments (files, streams and strings) from node.js to any smtp server
3
+ Send emails with ease!
4
4
 
5
- ## INSTALLING
5
+ This library lets you send rich HTML emails,
6
+ attachments (from files, streams, or strings), and plain text messages to any
7
+ SMTP server.
6
8
 
7
- npm install emailjs
9
+ [![checks](https://github.com/eleith/emailjs/actions/workflows/check.yml/badge.svg)](https://github.com/eleith/emailjs/actions/workflows/check.yml)
8
10
 
9
- ## FEATURES
11
+ ## What's to expect from emailjs? ๐Ÿš€
10
12
 
11
- - works with SSL and TLS smtp servers
12
- - supports smtp authentication ('PLAIN', 'LOGIN', 'CRAM-MD5', 'XOAUTH2')
13
- - emails are queued and the queue is sent asynchronously
14
- - supports sending html emails and emails with multiple attachments (MIME)
15
- - attachments can be added as strings, streams or file paths
16
- - supports utf-8 headers and body
17
- - built-in type declarations
18
- - automatically handles [greylisting](http://projects.puremagic.com/greylisting/whitepaper.html)
13
+ * **SSL and TLS Support:** Secure connections to your SMTP servers.
14
+ * **Authentication Galore:** Supports popular SMTP authentication methods like
15
+ `PLAIN`, `LOGIN`, `CRAM-MD5`, and `XOAUTH2`.
16
+ * **Asynchronous Sending:** Emails are queued and sent in the
17
+ background.
18
+ * **Rich Content:** Send HTML emails and include multiple attachments.
19
+ * **Flexible Attachments:** Attachments can be files, data streams, or plain
20
+ strings.
21
+ * **UTF-8 Ready:** Full support for UTF-8 in headers and body.
22
+ * **Built-in Type Declarations:** first-class TypeScript support.
23
+ * **Greylisting Awareness:** Automatically handles
24
+ [greylisting](http://projects.puremagic.com/greylisting/whitepaper.html) to
25
+ improve deliverability.
19
26
 
20
- ## REQUIRES
27
+ ## Get Started! ๐Ÿ› ๏ธ
21
28
 
22
- - auth access to an SMTP Server
23
- - if your service (ex: gmail) uses two-step authentication, use an application specific password
29
+ ### Installing
24
30
 
25
- ## EXAMPLE USAGE - text only emails
31
+ It's super simple!
26
32
 
27
- ```js
28
- import { SMTPClient } from 'emailjs';
29
-
30
- const client = new SMTPClient({
31
- user: 'user',
32
- password: 'password',
33
- host: 'smtp.your-email.com',
34
- ssl: true,
35
- });
36
-
37
- // send the message and get a callback with an error or details of the message that was sent
38
- client.send(
39
- {
40
- text: 'i hope this works',
41
- from: 'you <username@your-email.com>',
42
- to: 'someone <someone@your-email.com>, another <another@your-email.com>',
43
- cc: 'else <else@your-email.com>',
44
- subject: 'testing emailjs',
45
- },
46
- (err, message) => {
47
- console.log(err || message);
48
- }
49
- );
33
+ ```bash
34
+ npm install emailjs
50
35
  ```
51
36
 
52
- ## EXAMPLE USAGE - using async/await
37
+ ### Requirements
53
38
 
54
- ```js
55
- // assuming top-level await for brevity
56
- import { SMTPClient } from 'emailjs';
39
+ * Access to an SMTP Server.
40
+ * If your email service (like Gmail) uses two-step verification, you'll need an
41
+ application-specific password.
57
42
 
58
- const client = new SMTPClient({
59
- user: 'user',
60
- password: 'password',
61
- host: 'smtp.your-email.com',
62
- ssl: true,
63
- });
43
+ ### Quick Examples ๐Ÿง‘โ€๐Ÿ’ป
64
44
 
65
- try {
66
- const message = await client.sendAsync({
67
- text: 'i hope this works',
68
- from: 'you <username@your-email.com>',
69
- to: 'someone <someone@your-email.com>, another <another@your-email.com>',
70
- cc: 'else <else@your-email.com>',
71
- subject: 'testing emailjs',
72
- });
73
- console.log(message);
74
- } catch (err) {
75
- console.error(err);
76
- }
77
- ```
45
+ Here's how easy it is to send emails:
78
46
 
79
- ## EXAMPLE USAGE - html emails and attachments
47
+ #### Text-Only Emails
80
48
 
81
- ```js
49
+ ```javascript
82
50
  import { SMTPClient } from 'emailjs';
83
51
 
84
52
  const client = new SMTPClient({
85
- user: 'user',
86
- password: 'password',
87
- host: 'smtp.your-email.com',
88
- ssl: true,
53
+ user: 'your-username',
54
+ password: 'your-password',
55
+ host: 'smtp.your-email.com',
56
+ ssl: true, // Use SSL for secure connection
89
57
  });
90
58
 
91
- const message = {
92
- text: 'i hope this works',
93
- from: 'you <username@your-email.com>',
94
- to: 'someone <someone@your-email.com>, another <another@your-email.com>',
95
- cc: 'else <else@your-email.com>',
96
- subject: 'testing emailjs',
97
- attachment: [
98
- { data: '<html>i <i>hope</i> this works!</html>', alternative: true },
99
- { path: 'path/to/file.zip', type: 'application/zip', name: 'renamed.zip' },
100
- ],
101
- };
102
-
103
- // send the message and get a callback with an error or details of the message that was sent
104
- client.send(message, function (err, message) {
105
- console.log(err || message);
106
- });
107
-
108
- // you can continue to send more messages with successive calls to 'client.send',
109
- // they will be queued on the same smtp connection
59
+ async function sendMyEmail() {
60
+ try {
61
+ const message = await client.sendAsync({
62
+ text: 'Hello from emailjs! This is a test message.',
63
+ from: 'You <your-email@example.com>',
64
+ to: 'Someone <someone@example.com>',
65
+ subject: 'Exciting News from emailjs! ๐ŸŽ‰',
66
+ });
67
+ console.log('Email sent successfully:', message);
68
+ } catch (err) {
69
+ console.error('Failed to send email:', err);
70
+ } finally {
71
+ client.smtp.close(); // Don't forget to close the connection!
72
+ }
73
+ }
110
74
 
111
- // or instead of using the built-in client you can create an instance of 'smtp.SMTPConnection'
75
+ sendMyEmail();
112
76
  ```
113
77
 
114
- ## EXAMPLE USAGE - sending through outlook
78
+ #### HTML Emails & Attachments
115
79
 
116
- ```js
80
+ ```javascript
117
81
  import { SMTPClient, Message } from 'emailjs';
118
82
 
119
83
  const client = new SMTPClient({
120
- user: 'user',
121
- password: 'password',
122
- host: 'smtp-mail.outlook.com',
123
- tls: {
124
- ciphers: 'SSLv3',
125
- },
84
+ user: 'your-username',
85
+ password: 'your-password',
86
+ host: 'smtp.your-email.com',
87
+ tls: true,
126
88
  });
127
89
 
128
- const message = new Message({
129
- text: 'i hope this works',
130
- from: 'you <username@outlook.com>',
131
- to: 'someone <someone@your-email.com>, another <another@your-email.com>',
132
- cc: 'else <else@your-email.com>',
133
- subject: 'testing emailjs',
134
- attachment: [
135
- { data: '<html>i <i>hope</i> this works!</html>', alternative: true },
136
- { path: 'path/to/file.zip', type: 'application/zip', name: 'renamed.zip' },
137
- ],
138
- });
90
+ async function sendRichEmail() {
91
+ const htmlContent = `
92
+ <h1>Greetings!</h1>
93
+ <p>This is an <b>HTML email</b> with a lovely picture and an attachment.</p>
94
+ <img src="cid:my-image" alt="Embedded Image" width="150" height="100">
95
+ <p>Check out the attached file!</p>
96
+ `;
97
+
98
+ const message = new Message({
99
+ from: 'You <your-email@example.com>',
100
+ to: 'Someone <someone@example.com>',
101
+ subject: 'Your Awesome HTML Email! ๐Ÿ–ผ๏ธ๐Ÿ“„',
102
+ attachment: [
103
+ {
104
+ data: htmlContent,
105
+ alternative: true, // This part is the HTML body
106
+ contentType: 'text/html',
107
+ },
108
+ {
109
+ path: 'path/to/your/document.pdf', // Attach a file from disk
110
+ type: 'application/pdf',
111
+ name: 'document.pdf',
112
+ },
113
+ {
114
+ path: 'path/to/your/image.jpg', // Embed an image for the HTML
115
+ type: 'image/jpeg',
116
+ name: 'cool_image.jpg',
117
+ // Reference in HTML with cid:my-image
118
+ headers: { 'Content-ID': '<my-image>' },
119
+ },
120
+ ],
121
+ });
122
+
123
+ try {
124
+ await client.sendAsync(message);
125
+ console.log('Rich email sent successfully!');
126
+ } catch (err) {
127
+ console.error('Failed to send rich email:', err);
128
+ } finally {
129
+ client.smtp.close();
130
+ }
131
+ }
139
132
 
140
- // send the message and get a callback with an error or details of the message that was sent
141
- client.send(message, (err, message) => {
142
- console.log(err || message);
143
- });
133
+ sendRichEmail();
144
134
  ```
145
135
 
146
- ## EXAMPLE USAGE - attaching and embedding an image
136
+ ## API Reference ๐Ÿ“–
147
137
 
148
- ```js
149
- import { SMTPClient, Message } from 'emailjs';
138
+ The `emailjs` library is fully typed, here is a brief overview of most likely to
139
+ be used methods
150
140
 
151
- const client = new SMTPClient({
152
- user: 'user',
153
- password: 'password',
154
- host: 'smtp-mail.outlook.com',
155
- tls: {
156
- ciphers: 'SSLv3',
157
- },
158
- });
141
+ ### `new SMTPClient(options)`
159
142
 
160
- const message = new Message({
161
- text: 'i hope this works',
162
- from: 'you <username@outlook.com>',
163
- to: 'someone <someone@your-email.com>, another <another@your-email.com>',
164
- cc: 'else <else@your-email.com>',
165
- subject: 'testing emailjs',
166
- attachment: [
167
- {
168
- data:
169
- '<html>i <i>hope</i> this works! here is an image: <img src="cid:my-image" width="100" height ="50"> </html>',
170
- },
171
- { path: 'path/to/file.zip', type: 'application/zip', name: 'renamed.zip' },
172
- {
173
- path: 'path/to/image.jpg',
174
- type: 'image/jpg',
175
- headers: { 'Content-ID': '<my-image>' },
176
- },
177
- ],
178
- });
143
+ Create a new client instance to connect to your SMTP server.
179
144
 
180
- // send the message and get a callback with an error or details of the message that was sent
181
- client.send(message, (err, message) => {
182
- console.log(err || message);
183
- });
145
+ ```javascript
146
+ const options = {
147
+ user: 'your-username', // ๐Ÿ”‘ Username for logging into SMTP
148
+ password: 'your-password', // ๐Ÿคซ Password for logging into SMTP
149
+ host: 'smtp.your-email.com', // ๐ŸŒ SMTP server host (defaults to 'localhost')
150
+ port: 587, // ๐Ÿ”Œ SMTP port (defaults: 25 unencrypted, 465 SSL, 587 TLS)
151
+ ssl: true, // ๐Ÿ”’ Boolean or object for immediate SSL connection
152
+ tls: true, // ๐Ÿ” Boolean or object (see typescript types) to initiate STARTTLS
153
+ timeout: 5000, // โณ Max milliseconds to wait for SMTP responses
154
+ domain: 'your-domain.com', // ๐Ÿ  Domain to greet SMTP with (defaults to os.hostname)
155
+ authentication: ['PLAIN', 'LOGIN'], // ๐Ÿค Preferred authentication methods
156
+ logger: console, // ๐Ÿ“ Override the built-in logger (e.g., custom logging)
157
+ };
184
158
  ```
185
159
 
186
- # API
160
+ ### `SMTPClient#send(message, callback)`
187
161
 
188
- ## new SMTPClient(options)
162
+ Sends an email message. You can pass a `Message` instance or a headers object.
189
163
 
190
- ```js
191
- // options is an object with the following recognized schema:
192
- const options = {
193
- user, // username for logging into smtp
194
- password, // password for logging into smtp
195
- host, // smtp host (defaults to 'localhost')
196
- port, // smtp port (defaults to 25 for unencrypted, 465 for `ssl`, and 587 for `tls`)
197
- ssl, // boolean or object (if true or object, ssl connection will be made)
198
- tls, // boolean or object (if true or object, starttls will be initiated)
199
- timeout, // max number of milliseconds to wait for smtp responses (defaults to 5000)
200
- domain, // domain to greet smtp with (defaults to os.hostname)
201
- authentication, // array of preferred authentication methods ('PLAIN', 'LOGIN', 'CRAM-MD5', 'XOAUTH2')
202
- logger, // override the built-in logger (useful for e.g. Azure Function Apps, where console.log doesn't work)
203
- };
204
- // ssl/tls objects are an abbreviated form of [`tls.connect`](https://nodejs.org/dist/latest-v14.x/docs/api/tls.html#tls_tls_connect_options_callback)'s options
205
- // the missing items are: `port`, `host`, `path`, `socket`, `timeout` and `secureContext`
206
- // NOTE: `host` is trimmed before being used to establish a connection;
207
- // however, the original untrimmed value will still be visible in configuration.
164
+ ```javascript
165
+ client.send(messageObject, (err, details) => {
166
+ if (err) console.error(err);
167
+ else console.log('Message sent:', details);
168
+ });
208
169
  ```
209
170
 
210
- ## SMTPClient#send(message, callback)
171
+ ### `SMTPClient#sendAsync(message)`
211
172
 
212
- ```js
213
- // message can be a smtp.Message (as returned by email.message.create)
214
- // or an object identical to the first argument accepted by email.message.create
173
+ a promise-based way to send emails! โœจ
215
174
 
216
- // callback will be executed with (err, message)
217
- // either when message is sent or an error has occurred
175
+ ```javascript
176
+ try {
177
+ const details = await client.sendAsync(messageObject);
178
+ console.log('Message sent:', details);
179
+ } catch (err) {
180
+ console.error('Failed to send:', err);
181
+ }
218
182
  ```
219
183
 
220
- ## new Message(headers)
184
+ ### `new Message(headers)`
185
+
186
+ Constructs an RFC2822-compliant message object.
221
187
 
222
- ```js
223
- // headers is an object with the following recognized schema:
188
+ ```javascript
224
189
  const headers = {
225
- from, // sender of the format (address or name <address> or "name" <address>)
226
- to, // recipients (same format as above), multiple recipients are separated by a comma
227
- cc, // carbon copied recipients (same format as above)
228
- bcc, // blind carbon copied recipients (same format as above)
229
- text, // text of the email
230
- subject, // string subject of the email
231
- attachment, // one attachment or array of attachments
190
+ from: 'sender@example.com', // ๐Ÿ’Œ Sender (required!)
191
+ to: 'recipient@example.com', // ๐Ÿ“ฌ Recipients (at least one of to, cc, or bcc)
192
+ cc: 'carbon-copy@example.com', // ๐Ÿ‘ฅ CC recipients
193
+ bcc: 'blind-copy@example.com', // ๐Ÿ•ต๏ธโ€โ™€๏ธ BCC recipients
194
+ subject: 'Your Subject Here', // ๐Ÿ“ Email subject
195
+ text: 'Plain text body.', // ๐Ÿ—’๏ธ Plain text content
196
+ attachment: [{ data: 'Hello!' }], // ๐Ÿ“Ž One or more attachments
232
197
  };
233
- // the `from` field is required.
234
- // at least one `to`, `cc`, or `bcc` header is also required.
235
- // you can also add whatever other headers you want.
236
198
  ```
237
199
 
238
- ## Message#attach(options)
200
+ ### `Message#attach(options)`
239
201
 
240
- Can be called multiple times, each adding a new attachment.
202
+ Adds an attachment to the message. Can be called multiple times.
241
203
 
242
- ```js
243
- // options is an object with the following recognized schema:
244
- const options = {
245
- // one of these fields is required
246
- path, // string to where the file is located
247
- data, // string of the data you want to attach
248
- stream, // binary stream that will provide attachment data (make sure it is in the paused state)
249
- // better performance for binary streams is achieved if buffer.length % (76*6) == 0
250
- // current max size of buffer must be no larger than Message.BUFFERSIZE
251
-
252
- // optionally these fields are also accepted
253
- type, // string of the file mime type
254
- name, // name to give the file as perceived by the recipient
255
- charset, // charset to encode attatchment in
256
- method, // method to send attachment as (used by calendar invites)
257
- alternative, // if true, will be attached inline as an alternative (also defaults type='text/html')
258
- inline, // if true, will be attached inline
259
- encoded, // set this to true if the data is already base64 encoded, (avoid this if possible)
260
- headers, // object containing header=>value pairs for inclusion in this attachment's header
261
- related, // an array of attachments that you want to be related to the parent attachment
262
- };
204
+ ```javascript
205
+ message.attach({
206
+ path: 'path/to/file.zip', // ๐Ÿ“ Path to a file on disk
207
+ data: 'Binary content as string or buffer', // ๐Ÿ“„ Raw data
208
+ stream: fs.createReadStream('file.jpg'), // ๐ŸŒŠ A readable stream
209
+ type: 'application/zip', // MIME type
210
+ name: 'custom-name.zip', // Filename perceived by recipient
211
+ alternative: true, // attach inline as an alternative (e.g., HTML body)
212
+ inline: true, // If true, attached inline (e.g., for <img src="cid:...">)
213
+ headers: { 'X-Custom-Header': 'value' }, // Custom attachment headers
214
+ });
263
215
  ```
264
216
 
265
- ## Message#checkValidity()
217
+ ### `Message#checkValidity()`
266
218
 
267
- Synchronously validate that a Message is properly formed.
219
+ Synchronously validates that a `Message` is properly formed before sending.
268
220
 
269
- ```js
270
- const message = new Message(options);
221
+ ```javascript
271
222
  const { isValid, validationError } = message.checkValidity();
272
- if (isValid) {
273
- // ...
274
- } else {
275
- // first error encountered
276
- console.error(validationError);
223
+ if (!isValid) {
224
+ console.error('Message is invalid:', validationError);
277
225
  }
278
226
  ```
279
227
 
280
- ## new SMTPConnection(options={})
228
+ ## Authors โœ๏ธ
281
229
 
282
- ```js
283
- // options is an object with the following recognized schema:
284
- const options = {
285
- user, // username for logging into smtp
286
- password, // password for logging into smtp
287
- host, // smtp host (defaults to 'localhost')
288
- port, // smtp port (defaults to 25 for unencrypted, 465 for `ssl`, and 587 for `tls`)
289
- ssl, // boolean or object (if true or object, ssl connection will be made)
290
- tls, // boolean or object (if true or object, starttls will be initiated)
291
- timeout, // max number of milliseconds to wait for smtp responses (defaults to 5000)
292
- domain, // domain to greet smtp with (defaults to os.hostname)
293
- authentication, // array of preferred authentication methods ('PLAIN', 'LOGIN', 'CRAM-MD5', 'XOAUTH2')
294
- logger, // override the built-in logger (useful for e.g. Azure Function Apps, where console.log doesn't work)
295
- };
296
- // ssl/tls objects are an abbreviated form of [`tls.connect`](https://nodejs.org/dist/latest-v14.x/docs/api/tls.html#tls_tls_connect_options_callback)'s options
297
- // the missing items are: `port`, `host`, `path`, `socket`, `timeout` and `secureContext`
298
- // NOTE: `host` is trimmed before being used to establish a connection;
299
- // however, the original untrimmed value will still be visible in configuration.
230
+ * eleith
231
+ * zackschuster
232
+
233
+ ## Testing ๐Ÿงช
234
+
235
+ ```bash
236
+ # Run all tests
237
+ npm test
238
+
239
+ # Run tests with code coverage report
240
+ npm run test:coverage
300
241
  ```
301
242
 
302
- To target a Message Transfer Agent (MTA), omit all options.
243
+ ## Development ๐Ÿง‘โ€๐Ÿ’ป๐ŸŒฑ
244
+
245
+ for a local smtp testing experience, use our
246
+ [Mailpit](https://mailpit.axllent.org/) compose service
247
+
248
+ ### 1. Start Mailpit with Docker Compose
249
+
250
+ Ensure you have Docker and Docker Compose installed.
251
+
252
+ ```bash
253
+ # From the project root, start Mailpit
254
+ docker compose up
255
+ ```
303
256
 
304
- ## SMTPConnection#authentication
257
+ Mailpit will be accessible via:
305
258
 
306
- associative array of currently supported SMTP authentication mechanisms
259
+ * **Web UI:** `http://localhost:8025`
260
+ * **SMTP Server:** `localhost:1025`
307
261
 
308
- ## Authors
262
+ ### 2. Run Example Sending Scripts
309
263
 
310
- eleith
311
- zackschuster
264
+ You can use the provided scripts to send different types of emails to your local
265
+ Mailpit instance.
312
266
 
313
- ## Testing
267
+ First, make sure the `emailjs` library is built:
314
268
 
315
- npm install -d
316
- npm test
269
+ ```bash
270
+ npm run build
271
+ ```
272
+
273
+ Then, run any of the example scripts:
274
+
275
+ ```bash
276
+ # Send a plain text email
277
+ node scripts/send-text.js
278
+
279
+ # Send an HTML email
280
+ node scripts/send-html.js
281
+
282
+ # Send an email with attachments
283
+ node scripts/send-attachment.js
284
+ ```
317
285
 
318
- ## Contributions
286
+ After running a script, open your Mailpit Web UI (`http://localhost:8025`) to
287
+ see the emails stream in! ๐Ÿ“ฉ
319
288
 
320
- issues and pull requests are welcome
@@ -0,0 +1,6 @@
1
+ export interface AddressObject {
2
+ address?: string;
3
+ name?: string;
4
+ group?: AddressObject[];
5
+ }
6
+ export declare function addressparser(address?: string | string[]): AddressObject[];