@tryghost/nodemailer 0.2.0 → 0.3.3
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/lib/nodemailer.js +29 -8
- package/package.json +4 -3
package/lib/nodemailer.js
CHANGED
|
@@ -22,6 +22,17 @@ module.exports = function (transport, options = {}) {
|
|
|
22
22
|
case 'smtp':
|
|
23
23
|
transportOptions = options;
|
|
24
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
|
+
|
|
25
36
|
if (options.service && options.service.toLowerCase() === 'sendmail') {
|
|
26
37
|
transportOptions.sendmail = true;
|
|
27
38
|
}
|
|
@@ -35,15 +46,15 @@ module.exports = function (transport, options = {}) {
|
|
|
35
46
|
|
|
36
47
|
const pattern = /(.*)email(.*)\.(.*).amazonaws.com/i;
|
|
37
48
|
const result = pattern.exec(options.ServiceUrl);
|
|
49
|
+
const region = options.region || (result && result[3]) || 'us-east-1';
|
|
38
50
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
sesOptions.secretAccessKey = sesOptions.secretAccessKey || sesOptions.AWSSecretKey;
|
|
42
|
-
sesOptions.sessionToken = sesOptions.sessionToken || sesOptions.AWSSecurityToken;
|
|
43
|
-
sesOptions.apiVersion = '2010-12-01';
|
|
44
|
-
sesOptions.region = sesOptions.region || (result && result[3]) || 'us-east-1';
|
|
51
|
+
process.env.AWS_ACCESS_KEY_ID = options.accessKeyId || options.AWSAccessKeyID;
|
|
52
|
+
process.env.AWS_SECRET_ACCESS_KEY = options.secretAccessKey || options.AWSSecretKey;
|
|
45
53
|
|
|
46
|
-
const ses = new aws.SES(
|
|
54
|
+
const ses = new aws.SES({
|
|
55
|
+
apiVersion: '2010-12-01',
|
|
56
|
+
region
|
|
57
|
+
});
|
|
47
58
|
|
|
48
59
|
transportOptions = {
|
|
49
60
|
SES: {ses, aws}
|
|
@@ -54,11 +65,21 @@ module.exports = function (transport, options = {}) {
|
|
|
54
65
|
const directTransport = require('nodemailer-direct-transport');
|
|
55
66
|
transportOptions = directTransport(options);
|
|
56
67
|
break;
|
|
68
|
+
case 'stub':
|
|
69
|
+
const stubTransport = require('nodemailer-stub-transport');
|
|
70
|
+
transportOptions = stubTransport(options);
|
|
71
|
+
break;
|
|
57
72
|
default:
|
|
58
73
|
throw new errors.EmailError({
|
|
59
74
|
message: tpl(messages.unknownTransport, {transport})
|
|
60
75
|
});
|
|
61
76
|
}
|
|
62
77
|
|
|
63
|
-
|
|
78
|
+
const transporter = nodemailer.createTransport(transportOptions);
|
|
79
|
+
|
|
80
|
+
if (transport === 'smtp') {
|
|
81
|
+
Object.assign(transporter.transporter.options, options);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return transporter;
|
|
64
85
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/nodemailer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"repository": "https://github.com/TryGhost/framework/tree/main/packages/nodemailer",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"@aws-sdk/client-ses": "^3.31.0",
|
|
29
29
|
"@tryghost/errors": "^0.2.13",
|
|
30
30
|
"nodemailer": "^6.6.3",
|
|
31
|
-
"nodemailer-direct-transport": "^3.3.2"
|
|
31
|
+
"nodemailer-direct-transport": "^3.3.2",
|
|
32
|
+
"nodemailer-stub-transport": "^1.1.0"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "11e16c956154da3e97f6d4d8a36a7491f614c4b8"
|
|
34
35
|
}
|