@timshel_npm/maildev 3.2.0 → 3.2.2

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 CHANGED
@@ -30,8 +30,8 @@ Or can be installed using [Github](https://docs.npmjs.com/cli/v10/configuring-np
30
30
  Ex:
31
31
  ```json
32
32
  "devDependencies": {
33
- "maildev": "github:timshel/maildev#3.2.0",
34
- "maildev": "npm:@timshel_npm/maildev@^3.2.0"
33
+ "maildev": "github:timshel/maildev#3.2.2",
34
+ "maildev": "npm:@timshel_npm/maildev@^3.2.2"
35
35
  }
36
36
  ```
37
37
 
@@ -226,7 +226,7 @@ class MailServer {
226
226
  return elt.id === id;
227
227
  });
228
228
  if (envelope) {
229
- return getDiskEmail(this.mailDir, envelope.id, envelope).then((mail) => {
229
+ return getDiskEmail(this.mailDir, envelope.id).then((mail) => {
230
230
  if (mail.html) {
231
231
  // sanitize html
232
232
  const window = new JSDOM("").window;
@@ -390,7 +390,7 @@ class MailServer {
390
390
  const saved = files.map(function (file) {
391
391
  return __awaiter(this, void 0, void 0, function* () {
392
392
  const id = path.parse(file).name;
393
- const email = yield getDiskEmail(self.mailDir, id, undefined);
393
+ const email = yield getDiskEmail(self.mailDir, id);
394
394
  return saveEmailToStore(self, email);
395
395
  });
396
396
  });
@@ -417,29 +417,27 @@ function createMailDir(mailDir) {
417
417
  fs.mkdirSync(mailDir, { recursive: true });
418
418
  logger.info("MailDev using directory %s", mailDir);
419
419
  }
420
- function getDiskEmail(mailDir, id, envelope) {
420
+ function getDiskEmail(mailDir, id) {
421
421
  return __awaiter(this, void 0, void 0, function* () {
422
422
  const emlPath = path.join(mailDir, id + ".eml");
423
423
  const data = yield fs_1.promises.readFile(emlPath, "utf8");
424
424
  const parsedMail = yield (0, mailparser_1.parse)(data);
425
- if (envelope === undefined) {
426
- envelope = {
427
- id: id,
428
- from: parsedMail.from,
429
- to: parsedMail.to,
430
- date: parsedMail.date,
431
- subject: parsedMail.subject,
432
- hasAttachment: parsedMail.attachments.length > 0,
433
- isRead: false,
434
- };
435
- }
436
- return buildMail(mailDir, envelope, parsedMail);
425
+ return buildMail(mailDir, id, parsedMail);
437
426
  });
438
427
  }
439
- function buildMail(mailDir, envelope, parsedMail) {
428
+ function buildMail(mailDir, id, parsedMail) {
440
429
  return __awaiter(this, void 0, void 0, function* () {
441
- const emlPath = path.join(mailDir, envelope.id + ".eml");
430
+ const emlPath = path.join(mailDir, id + ".eml");
442
431
  const stat = yield fs_1.promises.stat(emlPath);
432
+ const envelope = {
433
+ id: id,
434
+ from: parsedMail.from,
435
+ to: parsedMail.to,
436
+ date: parsedMail.date,
437
+ subject: parsedMail.subject,
438
+ hasAttachment: parsedMail.attachments.length > 0,
439
+ isRead: false,
440
+ };
443
441
  return Object.assign({ id: envelope.id, envelope, calculatedBcc: (0, bcc_1.calculateBcc)(envelope.to, parsedMail.to, parsedMail.cc), size: stat.size, sizeHuman: utils.formatBytes(stat.size) }, parsedMail);
444
442
  });
445
443
  }
@@ -482,16 +480,7 @@ function handleDataStream(mailServer, stream, session, callback) {
482
480
  });
483
481
  stream.pipe(emlStream);
484
482
  const parsed = yield (0, mailparser_1.parse)(stream);
485
- const envelope = {
486
- id: id,
487
- from: session.envelope.mailFrom,
488
- to: session.envelope.rcptTo,
489
- date: parsed.date,
490
- subject: parsed.subject,
491
- hasAttachment: parsed.attachments.length > 0,
492
- isRead: false,
493
- };
494
- const mail = yield buildMail(mailServer.mailDir, envelope, parsed);
483
+ const mail = yield buildMail(mailServer.mailDir, id, parsed);
495
484
  return saveEmailToStore(mailServer, mail);
496
485
  });
497
486
  }
@@ -139,7 +139,7 @@ function cliOptions() {
139
139
  hide8BITMIME: ((_a = config === null || config === void 0 ? void 0 : config.hideExtensions) !== null && _a !== void 0 ? _a : []).includes("8BITMIME"),
140
140
  hidePIPELINING: ((_b = config === null || config === void 0 ? void 0 : config.hideExtensions) !== null && _b !== void 0 ? _b : []).includes("PIPELINING"),
141
141
  hideSMTPUTF8: ((_c = config === null || config === void 0 ? void 0 : config.hideExtensions) !== null && _c !== void 0 ? _c : []).includes("SMTPUTF8"),
142
- outgoing: (config === null || config === void 0 ? void 0 : config.autoRelay) || (config === null || config === void 0 ? void 0 : config.autoRelayRules)
142
+ outgoing: (config === null || config === void 0 ? void 0 : config.autoRelay) || (config === null || config === void 0 ? void 0 : config.autoRelayRules) || (config === null || config === void 0 ? void 0 : config.outgoingHost)
143
143
  ? {
144
144
  host: config === null || config === void 0 ? void 0 : config.outgoingHost,
145
145
  port: config === null || config === void 0 ? void 0 : config.outgoingPort,
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Outgoing = void 0;
4
- /**
5
- * MailDev - outgoing
6
- */
7
4
  const SMTPConnection = require("nodemailer/lib/smtp-connection");
8
5
  const async = require("async");
9
6
  const fs = require("fs");
@@ -98,17 +95,19 @@ function createClient(outgoing) {
98
95
  }
99
96
  function relayMail(outgoing, emailObject, emailStream, isAutoRelay, done) {
100
97
  if (isAutoRelay && outgoing.autoRelayAddress) {
101
- emailObject.to = [{ address: outgoing.autoRelayAddress }];
102
- emailObject.envelope.to = [{ address: outgoing.autoRelayAddress, args: false }];
98
+ emailObject.to = [{ address: outgoing.autoRelayAddress, name: "Auto-Relay" }];
99
+ emailObject.envelope.to = [{ address: outgoing.autoRelayAddress, name: "Auto-Relay" }];
103
100
  }
104
101
  let recipients = emailObject.envelope.to.map(getAddressFromAddressObject);
105
102
  if (isAutoRelay && outgoing.autoRelayRules) {
106
103
  recipients = getAutoRelayableRecipients(recipients, outgoing.autoRelayRules);
107
104
  }
108
- // Fail silently with auth relay mode on
109
105
  if (recipients.length === 0) {
110
106
  return done("Email had no recipients");
111
107
  }
108
+ if (emailObject.envelope.from.length === 0) {
109
+ return done("Email had no sender");
110
+ }
112
111
  const mailSendCallback = function (err) {
113
112
  if (err) {
114
113
  logger.error("Outgoing client login error: ", err);
@@ -116,13 +115,13 @@ function relayMail(outgoing, emailObject, emailStream, isAutoRelay, done) {
116
115
  }
117
116
  const sender = getAddressFromAddressObject(emailObject.envelope.from);
118
117
  outgoing.client.send({
119
- from: sender,
118
+ from: emailObject.envelope.from[0].address,
120
119
  to: recipients,
121
120
  }, emailStream, function (err) {
122
121
  outgoing.client.quit();
123
122
  createClient(outgoing);
124
123
  if (err) {
125
- logger.error("Mail Delivery Error: ", err);
124
+ logger.error("Mail Delivery Error: ", err, { sender, recipients });
126
125
  return done(err);
127
126
  }
128
127
  logger.log("Mail Delivered: ", emailObject.subject);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@timshel_npm/maildev",
3
3
  "description": "SMTP Server with async API and Web Interface for viewing and testing emails during development",
4
- "version": "3.2.0",
4
+ "version": "3.2.2",
5
5
  "keywords": [
6
6
  "email",
7
7
  "e-mail",
@@ -55,40 +55,40 @@
55
55
  },
56
56
  "license": "MIT",
57
57
  "dependencies": {
58
- "@types/mailparser": "^3.4.6",
58
+ "@types/mailparser": "3.4.6",
59
59
  "addressparser": "1.0.1",
60
- "async": "^3.2.6",
61
- "commander": "^13.1.0",
62
- "compression": "^1.8.0",
63
- "cors": "^2.8.5",
64
- "dompurify": "^3.2.6",
65
- "express": "^5.1.0",
66
- "jsdom": "^26.1.0",
67
- "mailparser": "^3.7.3",
68
- "mime": "^3.0.0",
69
- "nodemailer": "^7.0.3",
70
- "smtp-server": "^3.14.0",
71
- "socket.io": "^4.8.1",
60
+ "async": "3.2.6",
61
+ "commander": "13.1.0",
62
+ "compression": "1.8.1",
63
+ "cors": "2.8.5",
64
+ "dompurify": "3.2.6",
65
+ "express": "5.1.0",
66
+ "jsdom": "26.1.0",
67
+ "mailparser": "3.7.4",
68
+ "mime": "3.0.0",
69
+ "nodemailer": "7.0.5",
70
+ "smtp-server": "3.14.0",
71
+ "socket.io": "4.8.1",
72
72
  "wildstring": "1.0.9"
73
73
  },
74
74
  "overrides": {
75
75
  "socket.io-adapter": "2.5.5"
76
76
  },
77
77
  "devDependencies": {
78
- "@types/express": "^4.17.23",
79
- "@types/node": "^18.19.112",
80
- "expect": "^30.0.3",
81
- "http-proxy-middleware": "^3.0.5",
82
- "jest": "^30.0.3",
83
- "jest-mock": "^30.0.2",
84
- "mocha": "^11.7.1",
85
- "nodemon": "^3.1.10",
86
- "nyc": "^17.1.0",
87
- "prettier": "^3.6.2",
88
- "sass": "^1.89.2",
89
- "ts-node": "^10.9.2",
90
- "ts-node-dev": "^2.0.0",
91
- "typescript": "^5.8.3"
78
+ "@types/express": "4.17.23",
79
+ "@types/node": "18.19.122",
80
+ "expect": "30.0.3",
81
+ "http-proxy-middleware": "3.0.5",
82
+ "jest": "30.0.5",
83
+ "jest-mock": "30.0.2",
84
+ "mocha": "11.7.1",
85
+ "nodemon": "3.1.10",
86
+ "nyc": "17.1.0",
87
+ "prettier": "3.6.2",
88
+ "sass": "1.90.0",
89
+ "ts-node": "10.9.2",
90
+ "ts-node-dev": "2.0.0",
91
+ "typescript": "5.9.2"
92
92
  },
93
93
  "engines": {
94
94
  "node": ">=18.0.0"