emailjs 3.7.0 → 3.8.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/package.json +12 -12
- package/smtp/client.ts +23 -13
- package/smtp/message.ts +8 -7
- package/CHANGELOG.md +0 -114
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emailjs",
|
|
3
3
|
"description": "send text/html emails and attachments (files, streams and strings) from node.js to any smtp server",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.8.0",
|
|
5
5
|
"author": "eleith",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"izuzak",
|
|
@@ -17,26 +17,26 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@ledge/configs": "23.3.23322",
|
|
20
|
-
"@rollup/plugin-typescript": "8.3.
|
|
20
|
+
"@rollup/plugin-typescript": "8.3.1",
|
|
21
21
|
"@types/mailparser": "3.4.0",
|
|
22
|
-
"@types/node": "
|
|
22
|
+
"@types/node": "17.0.21",
|
|
23
23
|
"@types/smtp-server": "3.5.7",
|
|
24
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
25
|
-
"@typescript-eslint/parser": "5.
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "5.15.0",
|
|
25
|
+
"@typescript-eslint/parser": "5.15.0",
|
|
26
26
|
"ava": "3.15.0",
|
|
27
27
|
"eslint": "7.32.0",
|
|
28
|
-
"eslint-config-prettier": "8.
|
|
28
|
+
"eslint-config-prettier": "8.5.0",
|
|
29
29
|
"eslint-plugin-prettier": "4.0.0",
|
|
30
30
|
"mailparser": "3.4.0",
|
|
31
|
-
"prettier": "2.
|
|
32
|
-
"rollup": "2.
|
|
33
|
-
"smtp-server": "3.
|
|
34
|
-
"ts-node": "10.
|
|
31
|
+
"prettier": "2.6.0",
|
|
32
|
+
"rollup": "2.70.1",
|
|
33
|
+
"smtp-server": "3.10.0",
|
|
34
|
+
"ts-node": "10.7.0",
|
|
35
35
|
"tslib": "2.3.1",
|
|
36
|
-
"typescript": "4.
|
|
36
|
+
"typescript": "4.6.2"
|
|
37
37
|
},
|
|
38
38
|
"resolutions": {
|
|
39
|
-
"nodemailer": "6.7.
|
|
39
|
+
"nodemailer": "6.7.2"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=10"
|
package/smtp/client.ts
CHANGED
|
@@ -2,8 +2,16 @@ import { addressparser } from './address';
|
|
|
2
2
|
import { Message, MessageAttachment, MessageHeaders } from './message';
|
|
3
3
|
import { SMTPConnection, SMTPConnectionOptions, SMTPState } from './connection';
|
|
4
4
|
|
|
5
|
+
export type MessageCallback<T = Message | MessageHeaders> = <
|
|
6
|
+
U extends Error | null,
|
|
7
|
+
V extends U extends Error ? T : Message
|
|
8
|
+
>(
|
|
9
|
+
err: U,
|
|
10
|
+
msg: V
|
|
11
|
+
) => void;
|
|
12
|
+
|
|
5
13
|
export interface MessageStack {
|
|
6
|
-
callback:
|
|
14
|
+
callback: MessageCallback;
|
|
7
15
|
message: Message;
|
|
8
16
|
attachment: MessageAttachment;
|
|
9
17
|
text: string;
|
|
@@ -36,14 +44,14 @@ export class SMTPClient {
|
|
|
36
44
|
/**
|
|
37
45
|
* @public
|
|
38
46
|
* @param {Message} msg the message to send
|
|
39
|
-
* @param {
|
|
47
|
+
* @param {MessageCallback} callback .
|
|
40
48
|
* @returns {void}
|
|
41
49
|
*/
|
|
42
|
-
public send(
|
|
43
|
-
msg:
|
|
44
|
-
callback:
|
|
50
|
+
public send<T extends Message | MessageHeaders>(
|
|
51
|
+
msg: T,
|
|
52
|
+
callback: MessageCallback<T>
|
|
45
53
|
) {
|
|
46
|
-
const message
|
|
54
|
+
const message =
|
|
47
55
|
msg instanceof Message
|
|
48
56
|
? msg
|
|
49
57
|
: this._canMakeMessage(msg)
|
|
@@ -74,13 +82,15 @@ export class SMTPClient {
|
|
|
74
82
|
* @param {Message} msg the message to send
|
|
75
83
|
* @returns {Promise<Message>} a promise that resolves to the fully processed message
|
|
76
84
|
*/
|
|
77
|
-
public sendAsync(msg: Message) {
|
|
85
|
+
public sendAsync(msg: Message | MessageHeaders) {
|
|
78
86
|
return new Promise<Message>((resolve, reject) => {
|
|
79
|
-
this.send(msg, (err,
|
|
87
|
+
this.send(msg, (err, message) => {
|
|
80
88
|
if (err != null) {
|
|
81
89
|
reject(err);
|
|
82
90
|
} else {
|
|
83
|
-
|
|
91
|
+
// unfortunately, the conditional type doesn't reach here
|
|
92
|
+
// fortunately, we only return a `Message` when err is null, so this is safe
|
|
93
|
+
resolve(message as Message);
|
|
84
94
|
}
|
|
85
95
|
});
|
|
86
96
|
});
|
|
@@ -90,12 +100,12 @@ export class SMTPClient {
|
|
|
90
100
|
* @public
|
|
91
101
|
* @description Converts a message to the raw object used by the internal stack.
|
|
92
102
|
* @param {Message} message message to convert
|
|
93
|
-
* @param {
|
|
103
|
+
* @param {MessageCallback} callback errback
|
|
94
104
|
* @returns {MessageStack} raw message object
|
|
95
105
|
*/
|
|
96
106
|
public createMessageStack(
|
|
97
107
|
message: Message,
|
|
98
|
-
callback:
|
|
108
|
+
callback: MessageCallback = function () {
|
|
99
109
|
/* ø */
|
|
100
110
|
}
|
|
101
111
|
) {
|
|
@@ -231,7 +241,7 @@ export class SMTPClient {
|
|
|
231
241
|
* @returns {boolean} whether the attachment contains inlined html
|
|
232
242
|
*/
|
|
233
243
|
protected _containsInlinedHtml(
|
|
234
|
-
attachment
|
|
244
|
+
attachment?: MessageAttachment | MessageAttachment[]
|
|
235
245
|
) {
|
|
236
246
|
if (Array.isArray(attachment)) {
|
|
237
247
|
return attachment.some((att) => {
|
|
@@ -247,7 +257,7 @@ export class SMTPClient {
|
|
|
247
257
|
* @param {MessageAttachment} attachment attachment
|
|
248
258
|
* @returns {boolean} whether the attachment is inlined html
|
|
249
259
|
*/
|
|
250
|
-
protected _isAttachmentInlinedHtml(attachment
|
|
260
|
+
protected _isAttachmentInlinedHtml(attachment?: MessageAttachment) {
|
|
251
261
|
return (
|
|
252
262
|
attachment &&
|
|
253
263
|
(attachment.data || attachment.path) &&
|
package/smtp/message.ts
CHANGED
|
@@ -68,19 +68,20 @@ export interface MessageHeaders {
|
|
|
68
68
|
| string
|
|
69
69
|
| string[]
|
|
70
70
|
| null
|
|
71
|
+
| undefined
|
|
71
72
|
| MessageAttachment
|
|
72
73
|
| MessageAttachment[];
|
|
73
|
-
'content-type'
|
|
74
|
-
'message-id'
|
|
75
|
-
'return-path'
|
|
76
|
-
date
|
|
74
|
+
'content-type'?: string;
|
|
75
|
+
'message-id'?: string;
|
|
76
|
+
'return-path'?: string | null;
|
|
77
|
+
date?: string;
|
|
77
78
|
from: string | string[];
|
|
78
79
|
to: string | string[];
|
|
79
|
-
cc
|
|
80
|
-
bcc
|
|
80
|
+
cc?: string | string[];
|
|
81
|
+
bcc?: string | string[];
|
|
81
82
|
subject: string;
|
|
82
83
|
text: string | null;
|
|
83
|
-
attachment
|
|
84
|
+
attachment?: MessageAttachment | MessageAttachment[];
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
let counter = 0;
|
package/CHANGELOG.md
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
All notable changes to this project will be documented in this file.
|
|
3
|
-
|
|
4
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
|
-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
|
-
|
|
7
|
-
## [3.6.1] - TBD
|
|
8
|
-
### Fixed
|
|
9
|
-
- remove call to deprecated `RegExp.prototype.compile` (causes build error on typescript@4.5)
|
|
10
|
-
|
|
11
|
-
## [3.6.0] - 2021-09-03
|
|
12
|
-
### Added
|
|
13
|
-
- support `tsc` compilation without `--esModuleInterop` or `--allowSyntheticDefaultImports` [#296](https://github.com/eleith/emailjs/pull/296)
|
|
14
|
-
- `Message#readAsync` API [#297](https://github.com/eleith/emailjs/pull/297)
|
|
15
|
-
- `Message#checkValidity` API [#298](https://github.com/eleith/emailjs/pull/298)
|
|
16
|
-
|
|
17
|
-
### Deprecated
|
|
18
|
-
- `Message#valid` API [#298](https://github.com/eleith/emailjs/pull/298)
|
|
19
|
-
|
|
20
|
-
## [3.5.0] - 2021-06-28
|
|
21
|
-
### Added
|
|
22
|
-
- support `tsc --noPropertyAccessFromIndexSignature` [#290](https://github.com/eleith/emailjs/pull/290)
|
|
23
|
-
|
|
24
|
-
### Fixed
|
|
25
|
-
- use `engines` field in `package.json` to signal node version support
|
|
26
|
-
|
|
27
|
-
## [3.4.0] - 2020-12-01
|
|
28
|
-
### Added
|
|
29
|
-
- `SMTPClient#sendAsync` API [#267](https://github.com/eleith/emailjs/issues/267)
|
|
30
|
-
- `isRFC2822Date` API
|
|
31
|
-
|
|
32
|
-
### Changed
|
|
33
|
-
- use `WeakSet` instead of `WeakMap` for greylist tracking
|
|
34
|
-
|
|
35
|
-
### Fixed
|
|
36
|
-
- use camelCase style for internal function names
|
|
37
|
-
- use correct types in jsdoc comments
|
|
38
|
-
|
|
39
|
-
## [3.3.0] - 2020-08-08
|
|
40
|
-
### Added
|
|
41
|
-
- greylist support [#202](https://github.com/eleith/emailjs/issues/202)
|
|
42
|
-
|
|
43
|
-
### Fixed
|
|
44
|
-
- check socket is writable before sending [#205](https://github.com/eleith/emailjs/issues/205)
|
|
45
|
-
|
|
46
|
-
## [3.2.1] - 2020-06-27
|
|
47
|
-
### Fixed
|
|
48
|
-
- use correct type for `MessageAttachment.stream` [#261](https://github.com/eleith/emailjs/issues/261)
|
|
49
|
-
- add missing types in mime functions [#262](https://github.com/eleith/emailjs/pull/262)
|
|
50
|
-
|
|
51
|
-
## [3.2.0] - 2020-06-19
|
|
52
|
-
### Added
|
|
53
|
-
- `addressparser` API (forked from dropped dependency) [#259](https://github.com/eleith/emailjs/issues/259)
|
|
54
|
-
- `mimeEncode`/`mimeWordEncode` APIs (forked from dropped dependency) [#247](https://github.com/eleith/emailjs/issues/247)
|
|
55
|
-
|
|
56
|
-
### Changed
|
|
57
|
-
- drop dependency on `addressparser` [#259](https://github.com/eleith/emailjs/issues/259)
|
|
58
|
-
- drop dependency on `emailjs-mime-codec` [#247](https://github.com/eleith/emailjs/issues/247)
|
|
59
|
-
|
|
60
|
-
### Fixed
|
|
61
|
-
- make `MessageAttachment` interface usable [#254](https://github.com/eleith/emailjs/issues/254)
|
|
62
|
-
- mend regression in address type validation [#252](https://github.com/eleith/emailjs/pull/252)
|
|
63
|
-
|
|
64
|
-
## [3.1.0] - 2020-06-19 [YANKED]
|
|
65
|
-
|
|
66
|
-
## [3.0.0] - 2020-05-28
|
|
67
|
-
### Added
|
|
68
|
-
- convert source to strict typescript, listed under the `types` field in `package.json`
|
|
69
|
-
- support "dual-package" ESM + CJS via [conditional exports](https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_conditional_exports) & `rollup`-generated bundles
|
|
70
|
-
- `SMTPClient#creatMessageStack` API [#229](https://github.com/eleith/emailjs/issues/229)
|
|
71
|
-
- `SMTPError` API
|
|
72
|
-
|
|
73
|
-
### Changed
|
|
74
|
-
- simplify public API [#249](https://github.com/eleith/emailjs/issues/249)
|
|
75
|
-
- rename `Client` -> `SMTPClient` [#249](https://github.com/eleith/emailjs/issues/249)
|
|
76
|
-
- rename `SMTPResponse` -> `SMTPResponseMonitor` [#249](https://github.com/eleith/emailjs/issues/249)
|
|
77
|
-
|
|
78
|
-
### Removed
|
|
79
|
-
- `Message#attach_alternative` API
|
|
80
|
-
- `makeSMTPError` API
|
|
81
|
-
|
|
82
|
-
### Fixed
|
|
83
|
-
- filter duplicate message recipients [#242](https://github.com/eleith/emailjs/issues/242)
|
|
84
|
-
- error when passing `password` without `user` [#199](https://github.com/eleith/emailjs/issues/199)
|
|
85
|
-
- trim `host` before connecting [#136](https://github.com/eleith/emailjs/issues/136)
|
|
86
|
-
|
|
87
|
-
## [2.2.0] - 2018-07-06
|
|
88
|
-
### Added
|
|
89
|
-
- expose rfc2822 date module
|
|
90
|
-
- annotate code with typescript-compatible jsdoc tags
|
|
91
|
-
|
|
92
|
-
### Changed
|
|
93
|
-
- drop dependency on `moment`
|
|
94
|
-
- drop dependency on `starttls`
|
|
95
|
-
|
|
96
|
-
### Fixed
|
|
97
|
-
- ensure timeout is set to default value [#225](https://github.com/eleith/emailjs/issues/225)
|
|
98
|
-
|
|
99
|
-
## [2.1.0] - 2018-06-09
|
|
100
|
-
### Added
|
|
101
|
-
- expose error module
|
|
102
|
-
|
|
103
|
-
### Changed
|
|
104
|
-
- handle errors with `fs.closeSync` instead of `fs.close`
|
|
105
|
-
- refactor to ES2015+ constructs
|
|
106
|
-
- lint & format with eslint + prettier
|
|
107
|
-
- drop optional dependency on `bufferjs`
|
|
108
|
-
|
|
109
|
-
### Fixed
|
|
110
|
-
- remove `new Buffer` calls
|
|
111
|
-
|
|
112
|
-
## [2.0.1] - 2018-02-11
|
|
113
|
-
### Added
|
|
114
|
-
- a new changelog
|