@bobfrankston/mailx 1.0.69 → 1.0.71
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/package.json +1 -1
- package/packages/mailx-imap/index.js +15 -6
package/package.json
CHANGED
|
@@ -13,6 +13,15 @@ import * as path from "node:path";
|
|
|
13
13
|
import { simpleParser } from "mailparser";
|
|
14
14
|
import { createTransport } from "nodemailer";
|
|
15
15
|
import * as os from "node:os";
|
|
16
|
+
/** Extract full error detail from imapflow errors */
|
|
17
|
+
function imapError(err) {
|
|
18
|
+
const parts = [err.message || "Unknown error"];
|
|
19
|
+
if (err.responseText)
|
|
20
|
+
parts.push(err.responseText);
|
|
21
|
+
if (err.responseStatus)
|
|
22
|
+
parts.push(`[${err.responseStatus}]`);
|
|
23
|
+
return parts.join(" — ");
|
|
24
|
+
}
|
|
16
25
|
/** Convert iflow address objects to our EmailAddress */
|
|
17
26
|
function toEmailAddress(addr) {
|
|
18
27
|
return {
|
|
@@ -183,8 +192,8 @@ export class ImapManager extends EventEmitter {
|
|
|
183
192
|
console.log(` [auth] ${account.id}: token valid`);
|
|
184
193
|
}
|
|
185
194
|
catch (e) {
|
|
186
|
-
console.error(` [auth] ${account.id}: ${e
|
|
187
|
-
this.emit("accountError", account.id, e
|
|
195
|
+
console.error(` [auth] ${account.id}: ${imapError(e)}`);
|
|
196
|
+
this.emit("accountError", account.id, imapError(e), "Re-authenticate: click the button below or run mailx -setup");
|
|
188
197
|
}
|
|
189
198
|
}
|
|
190
199
|
}
|
|
@@ -437,13 +446,13 @@ export class ImapManager extends EventEmitter {
|
|
|
437
446
|
}
|
|
438
447
|
}
|
|
439
448
|
catch (e) {
|
|
440
|
-
this.emit("syncError", accountId, e
|
|
441
|
-
console.error(`Sync error for ${accountId}: ${e
|
|
449
|
+
this.emit("syncError", accountId, imapError(e));
|
|
450
|
+
console.error(`Sync error for ${accountId}: ${imapError(e)}`);
|
|
442
451
|
// Emit user-facing error — always offer re-auth for OAuth accounts
|
|
443
452
|
const config = this.configs.get(accountId);
|
|
444
453
|
const isOAuth = !!config?.tokenProvider;
|
|
445
454
|
const hint = isOAuth ? "Authentication may have expired" : "Check server connectivity";
|
|
446
|
-
this.emit("accountError", accountId, e
|
|
455
|
+
this.emit("accountError", accountId, imapError(e), hint);
|
|
447
456
|
}
|
|
448
457
|
finally {
|
|
449
458
|
if (client)
|
|
@@ -1169,7 +1178,7 @@ export class ImapManager extends EventEmitter {
|
|
|
1169
1178
|
const prev = this.outboxBackoff.get(accountId);
|
|
1170
1179
|
const delay = prev ? Math.min((now - prev + 30000) * 2, 300000) : 30000;
|
|
1171
1180
|
this.outboxBackoff.set(accountId, now + delay);
|
|
1172
|
-
console.error(` [outbox] Error for ${accountId}: ${e
|
|
1181
|
+
console.error(` [outbox] Error for ${accountId}: ${imapError(e)} (retry in ${Math.round(delay / 1000)}s)`);
|
|
1173
1182
|
}
|
|
1174
1183
|
}
|
|
1175
1184
|
};
|