Skip to content

Commit 2bb94f2

Browse files
committed
fix: update nodemailer and remove decommissioned smtp-transport dependency
1 parent 034d08a commit 2bb94f2

3 files changed

Lines changed: 18 additions & 27 deletions

File tree

compute/mailjet.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,15 @@
2020

2121
// [START compute_send]
2222
const mailer = require('nodemailer');
23-
const smtp = require('nodemailer-smtp-transport');
24-
2523
async function mailjet() {
26-
const transport = mailer.createTransport(
27-
smtp({
28-
host: 'in.mailjet.com',
29-
port: 2525,
30-
auth: {
31-
user: process.env.MAILJET_API_KEY || '<your-mailjet-api-key',
32-
pass: process.env.MAILJET_API_SECRET || '<your-mailjet-api-secret>',
33-
},
34-
})
35-
);
24+
const transport = mailer.createTransport({
25+
host: 'in.mailjet.com',
26+
port: 2525,
27+
auth: {
28+
user: process.env.MAILJET_API_KEY || '<your-mailjet-api-key',
29+
pass: process.env.MAILJET_API_SECRET || '<your-mailjet-api-secret>',
30+
},
31+
});
3632

3733
const json = await transport.sendMail({
3834
from: 'ANOTHER_EMAIL@ANOTHER_EXAMPLE.COM', // From address

compute/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"dependencies": {
1717
"@google-cloud/compute": "^4.0.0",
1818
"@sendgrid/mail": "^8.0.0",
19-
"nodemailer": "^6.0.0",
20-
"nodemailer-smtp-transport": "^2.7.4",
19+
"nodemailer": "^9.0.0",
2120
"sinon": "^19.0.2"
2221
},
2322
"devDependencies": {

compute/test/mailjet.test.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ describe('mailjet', () => {
2424
it('should send an email', () => {
2525
proxyquire('../mailjet', {
2626
nodemailer: {
27-
createTransport: arg => {
28-
assert.strictEqual(arg, 'test');
27+
createTransport: options => {
28+
assert.deepStrictEqual(options, {
29+
host: 'in.mailjet.com',
30+
port: 2525,
31+
auth: {
32+
user: 'foo',
33+
pass: 'bar',
34+
},
35+
});
2936
return {
3037
sendMail: payload => {
3138
assert.deepStrictEqual(payload, {
@@ -39,17 +46,6 @@ describe('mailjet', () => {
3946
};
4047
},
4148
},
42-
'nodemailer-smtp-transport': options => {
43-
assert.deepStrictEqual(options, {
44-
host: 'in.mailjet.com',
45-
port: 2525,
46-
auth: {
47-
user: 'foo',
48-
pass: 'bar',
49-
},
50-
});
51-
return 'test';
52-
},
5349
});
5450
});
5551
});

0 commit comments

Comments
 (0)