emailjs 3.8.0 → 4.0.1

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.
@@ -1853,8 +1853,9 @@ class SMTPClient {
1853
1853
  }
1854
1854
  /**
1855
1855
  * @public
1856
- * @param {Message} msg the message to send
1857
- * @param {function(err: Error, msg: Message): void} callback .
1856
+ * @template {Message | MessageHeaders} T
1857
+ * @param {T} msg the message to send
1858
+ * @param {MessageCallback<T>} callback receiver for the error (if any) as well as the passed-in message / headers
1858
1859
  * @returns {void}
1859
1860
  */
1860
1861
  send(msg, callback) {
@@ -1882,17 +1883,20 @@ class SMTPClient {
1882
1883
  }
1883
1884
  /**
1884
1885
  * @public
1885
- * @param {Message} msg the message to send
1886
- * @returns {Promise<Message>} a promise that resolves to the fully processed message
1886
+ * @template {Message | MessageHeaders} T
1887
+ * @param {T} msg the message to send
1888
+ * @returns {Promise<T>} a promise that resolves to the passed-in message / headers
1887
1889
  */
1888
1890
  sendAsync(msg) {
1889
1891
  return new Promise((resolve, reject) => {
1890
- this.send(msg, (err, msg) => {
1892
+ this.send(msg, (err, message) => {
1891
1893
  if (err != null) {
1892
1894
  reject(err);
1893
1895
  }
1894
1896
  else {
1895
- resolve(msg);
1897
+ // unfortunately, the conditional type doesn't reach here
1898
+ // fortunately, we only return a `Message` when err is null, so this is safe
1899
+ resolve(message);
1896
1900
  }
1897
1901
  });
1898
1902
  });
@@ -1901,7 +1905,7 @@ class SMTPClient {
1901
1905
  * @public
1902
1906
  * @description Converts a message to the raw object used by the internal stack.
1903
1907
  * @param {Message} message message to convert
1904
- * @param {function(err: Error, msg: Message): void} callback errback
1908
+ * @param {MessageCallback} callback errback
1905
1909
  * @returns {MessageStack} raw message object
1906
1910
  */
1907
1911
  createMessageStack(message, callback = function () {
@@ -2118,4 +2122,4 @@ class SMTPClient {
2118
2122
  }
2119
2123
 
2120
2124
  export { AUTH_METHODS, BUFFERSIZE, DEFAULT_TIMEOUT, MIME64CHUNK, MIMECHUNK, Message, SMTPClient, SMTPConnection, SMTPError, SMTPErrorStates, SMTPResponseMonitor, SMTPState, addressparser, getRFC2822Date, getRFC2822DateUTC, isRFC2822Date, mimeEncode, mimeWordEncode };
2121
- //# sourceMappingURL=email.mjs.map
2125
+ //# sourceMappingURL=email.js.map
package/email.ts CHANGED
@@ -1,8 +1,8 @@
1
- export * from './smtp/address';
2
- export * from './smtp/client';
3
- export * from './smtp/connection';
4
- export * from './smtp/date';
5
- export * from './smtp/error';
6
- export * from './smtp/message';
7
- export * from './smtp/mime';
8
- export * from './smtp/response';
1
+ export * from './smtp/address.js';
2
+ export * from './smtp/client.js';
3
+ export * from './smtp/connection.js';
4
+ export * from './smtp/date.js';
5
+ export * from './smtp/error.js';
6
+ export * from './smtp/message.js';
7
+ export * from './smtp/mime.js';
8
+ export * from './smtp/response.js';
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.8.0",
4
+ "version": "4.0.1",
5
5
  "author": "eleith",
6
6
  "contributors": [
7
7
  "izuzak",
@@ -17,48 +17,52 @@
17
17
  "type": "module",
18
18
  "devDependencies": {
19
19
  "@ledge/configs": "23.3.23322",
20
- "@rollup/plugin-typescript": "8.3.1",
20
+ "@rollup/plugin-typescript": "8.3.2",
21
21
  "@types/mailparser": "3.4.0",
22
- "@types/node": "17.0.21",
22
+ "@types/node": "12.12.6",
23
23
  "@types/smtp-server": "3.5.7",
24
- "@typescript-eslint/eslint-plugin": "5.15.0",
25
- "@typescript-eslint/parser": "5.15.0",
26
- "ava": "3.15.0",
27
- "eslint": "7.32.0",
24
+ "@typescript-eslint/eslint-plugin": "5.21.0",
25
+ "@typescript-eslint/parser": "5.21.0",
26
+ "ava": "4.2.0",
27
+ "eslint": "8.14.0",
28
28
  "eslint-config-prettier": "8.5.0",
29
29
  "eslint-plugin-prettier": "4.0.0",
30
- "mailparser": "3.4.0",
31
- "prettier": "2.6.0",
32
- "rollup": "2.70.1",
33
- "smtp-server": "3.10.0",
30
+ "mailparser": "3.5.0",
31
+ "prettier": "2.6.2",
32
+ "rollup": "2.70.2",
33
+ "smtp-server": "3.11.0",
34
34
  "ts-node": "10.7.0",
35
- "tslib": "2.3.1",
36
- "typescript": "4.6.2"
35
+ "tslib": "2.4.0",
36
+ "typescript": "4.3.5"
37
+ },
38
+ "peerDependencies": {
39
+ "typescript": ">=4.3.5"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "typescript": {
43
+ "optional": true
44
+ }
37
45
  },
38
46
  "resolutions": {
39
- "nodemailer": "6.7.2"
47
+ "nodemailer": "6.7.4"
40
48
  },
41
49
  "engines": {
42
- "node": ">=10"
50
+ "node": ">=12"
43
51
  },
44
52
  "files": [
53
+ "email.js",
45
54
  "email.ts",
46
- "smtp",
47
- "rollup"
55
+ "smtp"
48
56
  ],
49
- "main": "./rollup/email.cjs",
50
57
  "types": "./email.ts",
51
58
  "exports": {
52
- "import": "./rollup/email.mjs",
53
- "require": "./rollup/email.cjs"
59
+ "default": "./email.js"
54
60
  },
55
61
  "scripts": {
56
62
  "build": "rollup -c rollup.config.ts",
57
63
  "lint": "eslint *.ts \"+(smtp|test)/*.ts\"",
58
- "tsc": "tsc",
59
- "test": "ava",
60
- "pretest-cjs": "npm run build",
61
- "test-cjs": "npm run test -- --node-arguments='--title=cjs'"
64
+ "pretest": "yarn build",
65
+ "test": "ava"
62
66
  },
63
67
  "license": "MIT"
64
68
  }
package/smtp/client.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { addressparser } from './address';
2
- import { Message, MessageAttachment, MessageHeaders } from './message';
3
- import { SMTPConnection, SMTPConnectionOptions, SMTPState } from './connection';
1
+ import { addressparser } from './address.js';
2
+ import type { MessageAttachment, MessageHeaders } from './message.js';
3
+ import { Message } from './message.js';
4
+ import type { SMTPConnectionOptions } from './connection.js';
5
+ import { SMTPConnection, SMTPState } from './connection.js';
4
6
 
5
7
  export type MessageCallback<T = Message | MessageHeaders> = <
6
8
  U extends Error | null,
@@ -43,14 +45,15 @@ export class SMTPClient {
43
45
 
44
46
  /**
45
47
  * @public
46
- * @param {Message} msg the message to send
47
- * @param {MessageCallback} callback .
48
+ * @template {Message | MessageHeaders} T
49
+ * @param {T} msg the message to send
50
+ * @param {MessageCallback<T>} callback receiver for the error (if any) as well as the passed-in message / headers
48
51
  * @returns {void}
49
52
  */
50
53
  public send<T extends Message | MessageHeaders>(
51
54
  msg: T,
52
55
  callback: MessageCallback<T>
53
- ) {
56
+ ): void {
54
57
  const message =
55
58
  msg instanceof Message
56
59
  ? msg
@@ -79,10 +82,11 @@ export class SMTPClient {
79
82
 
80
83
  /**
81
84
  * @public
82
- * @param {Message} msg the message to send
83
- * @returns {Promise<Message>} a promise that resolves to the fully processed message
85
+ * @template {Message | MessageHeaders} T
86
+ * @param {T} msg the message to send
87
+ * @returns {Promise<T>} a promise that resolves to the passed-in message / headers
84
88
  */
85
- public sendAsync(msg: Message | MessageHeaders) {
89
+ public sendAsync<T extends Message | MessageHeaders>(msg: T) {
86
90
  return new Promise<Message>((resolve, reject) => {
87
91
  this.send(msg, (err, message) => {
88
92
  if (err != null) {
@@ -2,15 +2,11 @@ import { createHmac } from 'crypto';
2
2
  import { EventEmitter } from 'events';
3
3
  import { Socket } from 'net';
4
4
  import { hostname } from 'os';
5
- import {
6
- connect,
7
- createSecureContext,
8
- ConnectionOptions,
9
- TLSSocket,
10
- } from 'tls';
5
+ import { connect, createSecureContext, TLSSocket } from 'tls';
6
+ import type { ConnectionOptions } from 'tls';
11
7
 
12
- import { SMTPError, SMTPErrorStates } from './error';
13
- import { SMTPResponseMonitor } from './response';
8
+ import { SMTPError, SMTPErrorStates } from './error.js';
9
+ import { SMTPResponseMonitor } from './response.js';
14
10
 
15
11
  /**
16
12
  * @readonly
@@ -187,7 +183,7 @@ export class SMTPConnection extends EventEmitter {
187
183
  this.password = () => password as string;
188
184
 
189
185
  if (typeof logger === 'function') {
190
- this.log = log;
186
+ this.log = logger;
191
187
  }
192
188
  }
193
189
 
package/smtp/message.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import type { PathLike } from 'fs';
1
2
  import {
2
- PathLike,
3
3
  existsSync,
4
4
  open as openFile,
5
5
  close as closeFile,
@@ -10,9 +10,9 @@ import { hostname } from 'os';
10
10
  import { Stream } from 'stream';
11
11
  import type { Readable } from 'stream';
12
12
 
13
- import { addressparser } from './address';
14
- import { getRFC2822Date } from './date';
15
- import { mimeWordEncode } from './mime';
13
+ import { addressparser } from './address.js';
14
+ import { getRFC2822Date } from './date.js';
15
+ import { mimeWordEncode } from './mime.js';
16
16
 
17
17
  const CRLF = '\r\n' as const;
18
18
 
package/smtp/response.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SMTPError, SMTPErrorStates } from './error';
1
+ import { SMTPError, SMTPErrorStates } from './error.js';
2
2
  import type { Socket } from 'net';
3
3
  import type { TLSSocket } from 'tls';
4
4