@tryghost/nodemailer 2.0.3 → 2.1.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/README.md +13 -15
- package/lib/nodemailer.js +65 -64
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -11,11 +11,13 @@ Provides pre-configured transport options for common transport services.
|
|
|
11
11
|
### Supported Transport Types
|
|
12
12
|
|
|
13
13
|
1. `smtp` - send via SMTP server.
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
- Detects when service: 'sendmail' is used and enables sendmail mode
|
|
15
16
|
|
|
16
17
|
2. `mailgun` - Allows using Mailgun with API key instead of via SMTP.
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
- `auth: { api_key: 'your-mailgun-api-key' }`
|
|
20
|
+
- Defaults to 60-second timeout.
|
|
19
21
|
|
|
20
22
|
3. `sendmail` - use local sendmail binary.
|
|
21
23
|
|
|
@@ -33,26 +35,22 @@ Factory for creating Nodemailer transports across SMTP, SES, Mailgun, Sendmail,
|
|
|
33
35
|
|
|
34
36
|
## Develop
|
|
35
37
|
|
|
36
|
-
This is a mono repository, managed with [
|
|
38
|
+
This is a mono repository, managed with [Nx](https://nx.dev).
|
|
37
39
|
|
|
38
40
|
Follow the instructions for the top-level repo.
|
|
39
|
-
1. `git clone` this repo & `cd` into it as usual
|
|
40
|
-
2. Run `yarn` to install top-level dependencies.
|
|
41
41
|
|
|
42
|
+
1. `git clone` this repo & `cd` into it as usual
|
|
43
|
+
2. Run `pnpm install` to install top-level dependencies.
|
|
42
44
|
|
|
43
45
|
## Run
|
|
44
46
|
|
|
45
|
-
- `
|
|
46
|
-
|
|
47
|
+
- `pnpm dev`
|
|
47
48
|
|
|
48
49
|
## Test
|
|
49
50
|
|
|
50
|
-
- `
|
|
51
|
-
- `
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
- `pnpm lint` runs oxlint
|
|
52
|
+
- `pnpm test` runs lint and tests
|
|
55
53
|
|
|
56
|
-
# Copyright & License
|
|
54
|
+
# Copyright & License
|
|
57
55
|
|
|
58
|
-
Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
|
|
56
|
+
Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
|
package/lib/nodemailer.js
CHANGED
|
@@ -5,7 +5,7 @@ const nodemailer = require('nodemailer');
|
|
|
5
5
|
const tpl = require('@tryghost/tpl');
|
|
6
6
|
|
|
7
7
|
const messages = {
|
|
8
|
-
unknownTransport: `Unknown mail transport: {transport}
|
|
8
|
+
unknownTransport: `Unknown mail transport: {transport}`,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -19,70 +19,71 @@ module.exports = function (transport, options = {}) {
|
|
|
19
19
|
transport = transport.toLowerCase();
|
|
20
20
|
|
|
21
21
|
switch (transport) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
case 'smtp':
|
|
23
|
+
transportOptions = options;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated `secureConnection` was removed in Nodemailer 1.0.2
|
|
27
|
+
* in favor of `secure` but Ghost has been recommending `secureConnection`
|
|
28
|
+
* and it's difficult to get everyone to switch at this point
|
|
29
|
+
*
|
|
30
|
+
* Therefore, we have to alias it here to keep things working
|
|
31
|
+
*/
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(options, 'secureConnection')) {
|
|
33
|
+
transportOptions.secure = options.secureConnection;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (options.service && options.service.toLowerCase() === 'sendmail') {
|
|
37
|
+
transportOptions.sendmail = true;
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
case 'mailgun':
|
|
41
|
+
const mailgunTransport = require('nodemailer-mailgun-transport');
|
|
42
|
+
|
|
43
|
+
// Default to 60s timeout if not set in `options`
|
|
44
|
+
if (!Object.prototype.hasOwnProperty.call(options, 'timeout')) {
|
|
45
|
+
options.timeout = 60000;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
transportOptions = mailgunTransport(options);
|
|
49
|
+
break;
|
|
50
|
+
case 'sendmail':
|
|
51
|
+
transportOptions = options;
|
|
37
52
|
transportOptions.sendmail = true;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
break;
|
|
75
|
-
case 'direct':
|
|
76
|
-
transportOptions = Object.assign({direct: true}, options);
|
|
77
|
-
break;
|
|
78
|
-
case 'stub':
|
|
79
|
-
const stubTransport = require('nodemailer-stub-transport');
|
|
80
|
-
transportOptions = stubTransport(options);
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
throw new errors.EmailError({
|
|
84
|
-
message: tpl(messages.unknownTransport, {transport})
|
|
85
|
-
});
|
|
53
|
+
break;
|
|
54
|
+
case 'ses':
|
|
55
|
+
const { SESv2Client, SendRawEmailCommand } = require('@aws-sdk/client-sesv2');
|
|
56
|
+
|
|
57
|
+
const pattern = /(.*)email(.*)\.(.*).amazonaws.com/i;
|
|
58
|
+
const result = pattern.exec(options.ServiceUrl);
|
|
59
|
+
const region = options.region || (result && result[3]) || 'us-east-1';
|
|
60
|
+
|
|
61
|
+
const accessKeyId = options.accessKeyId || options.AWSAccessKeyID;
|
|
62
|
+
const secretAccessKey = options.secretAccessKey || options.AWSSecretKey;
|
|
63
|
+
const credentials =
|
|
64
|
+
accessKeyId && secretAccessKey ? { accessKeyId, secretAccessKey } : undefined;
|
|
65
|
+
|
|
66
|
+
const sesClient = new SESv2Client({
|
|
67
|
+
region,
|
|
68
|
+
credentials,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
transportOptions = {
|
|
72
|
+
SES: { sesClient, SendRawEmailCommand },
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
break;
|
|
76
|
+
case 'direct':
|
|
77
|
+
transportOptions = Object.assign({ direct: true }, options);
|
|
78
|
+
break;
|
|
79
|
+
case 'stub':
|
|
80
|
+
const stubTransport = require('nodemailer-stub-transport');
|
|
81
|
+
transportOptions = stubTransport(options);
|
|
82
|
+
break;
|
|
83
|
+
default:
|
|
84
|
+
throw new errors.EmailError({
|
|
85
|
+
message: tpl(messages.unknownTransport, { transport }),
|
|
86
|
+
});
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
const transporter = nodemailer.createTransport(transportOptions);
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/nodemailer",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Ghost Foundation",
|
|
4
6
|
"repository": {
|
|
5
7
|
"type": "git",
|
|
6
8
|
"url": "git+https://github.com/TryGhost/framework.git",
|
|
7
9
|
"directory": "packages/nodemailer"
|
|
8
10
|
},
|
|
9
|
-
"author": "Ghost Foundation",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"main": "index.js",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"dev": "echo \"Implement me!\"",
|
|
14
|
-
"test": "NODE_ENV=testing vitest run --coverage --config ../../vitest.config.ts",
|
|
15
|
-
"lint": "eslint . --ext .js --cache",
|
|
16
|
-
"posttest": "yarn lint"
|
|
17
|
-
},
|
|
18
11
|
"files": [
|
|
19
12
|
"index.js",
|
|
20
13
|
"lib"
|
|
21
14
|
],
|
|
15
|
+
"main": "index.js",
|
|
22
16
|
"publishConfig": {
|
|
23
17
|
"access": "public"
|
|
24
18
|
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"sinon": "21.0.2"
|
|
27
|
-
},
|
|
28
19
|
"dependencies": {
|
|
29
|
-
"@aws-sdk/client-sesv2": "3.
|
|
30
|
-
"
|
|
31
|
-
"nodemailer": "8.0.2",
|
|
20
|
+
"@aws-sdk/client-sesv2": "3.1032.0",
|
|
21
|
+
"nodemailer": "8.0.5",
|
|
32
22
|
"nodemailer-mailgun-transport": "2.1.5",
|
|
33
|
-
"nodemailer-stub-transport": "1.1.0"
|
|
23
|
+
"nodemailer-stub-transport": "1.1.0",
|
|
24
|
+
"@tryghost/errors": "3.1.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"sinon": "21.1.2"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"dev": "echo \"Implement me!\"",
|
|
31
|
+
"test": "NODE_ENV=testing vitest run --coverage --config ../../vitest.config.ts",
|
|
32
|
+
"lint": "oxlint -c ../../.oxlintrc.json .",
|
|
33
|
+
"posttest": "pnpm run lint"
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|