@bobfrankston/rmfmail 1.2.232 → 1.2.233
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/client/android-bootstrap.bundle.js +164 -152
- package/client/android-bootstrap.bundle.js.map +4 -4
- package/client/app.bundle.js +10 -104
- package/client/app.bundle.js.map +4 -4
- package/client/components/message-list.js +0 -60
- package/client/components/message-list.js.map +1 -1
- package/client/components/message-list.ts +0 -56
- package/client/compose/compose.bundle.js +1 -12
- package/client/compose/compose.bundle.js.map +2 -2
- package/client/compose/compose.html +0 -8
- package/client/compose/ghost-text.js +0 -8
- package/client/compose/ghost-text.js.map +1 -1
- package/client/compose/ghost-text.ts +0 -6
- package/client/compose/spellcheck-core.js +0 -1
- package/client/compose/spellcheck-core.js.map +1 -1
- package/client/compose/spellcheck-core.ts +0 -1
- package/client/index.html +0 -8
- package/client/lib/local-service.js +0 -73
- package/client/lib/local-service.js.map +1 -1
- package/client/lib/local-service.ts +0 -71
- package/client/lib/local-store.js +0 -3
- package/client/lib/local-store.js.map +1 -1
- package/client/lib/local-store.ts +0 -4
- package/package.json +1 -3
- package/packages/mailx-host/index.d.ts +0 -1
- package/packages/mailx-host/index.d.ts.map +1 -1
- package/packages/mailx-host/index.js +0 -1
- package/packages/mailx-host/index.js.map +1 -1
- package/packages/mailx-host/index.ts +0 -1
- package/packages/mailx-host/package.json +1 -1
- package/packages/mailx-service/index.d.ts.map +1 -1
- package/packages/mailx-service/index.js +36 -139
- package/packages/mailx-service/index.js.map +1 -1
- package/packages/mailx-service/index.ts +36 -148
- package/packages/mailx-settings/cloud.d.ts +0 -5
- package/packages/mailx-settings/cloud.d.ts.map +1 -1
- package/packages/mailx-settings/cloud.js +0 -16
- package/packages/mailx-settings/cloud.js.map +1 -1
- package/packages/mailx-settings/cloud.ts +0 -12
- package/packages/mailx-settings/index.d.ts +0 -3
- package/packages/mailx-settings/index.d.ts.map +1 -1
- package/packages/mailx-settings/index.js +0 -5
- package/packages/mailx-settings/index.js.map +1 -1
- package/packages/mailx-settings/index.ts +0 -7
- package/packages/mailx-store-web/main-thread-host.d.ts +1 -1
- package/packages/mailx-store-web/main-thread-host.d.ts.map +1 -1
- package/packages/mailx-store-web/main-thread-host.js +1 -38
- package/packages/mailx-store-web/main-thread-host.js.map +1 -1
- package/packages/mailx-store-web/main-thread-host.ts +0 -42
- package/packages/mailx-store-web/package.json +1 -1
- package/packages/mailx-store-web/web-service.d.ts.map +1 -1
- package/packages/mailx-store-web/web-service.js +28 -114
- package/packages/mailx-store-web/web-service.js.map +1 -1
- package/packages/mailx-store-web/web-service.ts +28 -124
- package/packages/mailx-store-web/web-settings.d.ts +0 -4
- package/packages/mailx-store-web/web-settings.d.ts.map +1 -1
- package/packages/mailx-store-web/web-settings.js +0 -29
- package/packages/mailx-store-web/web-settings.js.map +1 -1
- package/packages/mailx-store-web/web-settings.ts +0 -24
- package/packages/mailx-types/index.d.ts +2 -0
- package/packages/mailx-types/index.d.ts.map +1 -1
- package/packages/mailx-types/index.js +1 -0
- package/packages/mailx-types/index.js.map +1 -1
- package/packages/mailx-types/index.ts +2 -0
- package/packages/mailx-types/mime-build.d.ts +74 -0
- package/packages/mailx-types/mime-build.d.ts.map +1 -0
- package/packages/mailx-types/mime-build.js +160 -0
- package/packages/mailx-types/mime-build.js.map +1 -0
- package/packages/mailx-types/mime-build.ts +217 -0
- package/packages/mailx-types/package.json +1 -1
- package/packages/mailx-types/test/mime-build.test.mjs +200 -0
- package/client/components/calendar.js +0 -220
- package/client/components/calendar.js.map +0 -1
- package/client/components/calendar.ts +0 -213
- package/client/components/tasks.js +0 -261
- package/client/components/tasks.js.map +0 -1
- package/client/components/tasks.ts +0 -234
- package/packages/mailx-compose/.gitattributes +0 -10
- package/packages/mailx-compose/index.d.ts +0 -21
- package/packages/mailx-compose/index.d.ts.map +0 -1
- package/packages/mailx-compose/index.js +0 -66
- package/packages/mailx-compose/index.js.map +0 -1
- package/packages/mailx-compose/index.ts +0 -91
- package/packages/mailx-compose/package.json +0 -18
- package/packages/mailx-compose/tsconfig.json +0 -9
- package/packages/mailx-core/index.d.ts +0 -142
- package/packages/mailx-core/index.d.ts.map +0 -1
- package/packages/mailx-core/index.js +0 -430
- package/packages/mailx-core/index.js.map +0 -1
- package/packages/mailx-core/index.ts +0 -450
- package/packages/mailx-core/ipc.d.ts +0 -13
- package/packages/mailx-core/ipc.d.ts.map +0 -1
- package/packages/mailx-core/ipc.js +0 -56
- package/packages/mailx-core/ipc.js.map +0 -1
- package/packages/mailx-core/ipc.ts +0 -62
- package/packages/mailx-core/package.json +0 -18
- package/packages/mailx-core/tsconfig.json +0 -9
- package/packages/mailx-send/.gitattributes +0 -10
- package/packages/mailx-send/README.md +0 -217
- package/packages/mailx-send/cli-queue.d.ts +0 -11
- package/packages/mailx-send/cli-queue.d.ts.map +0 -1
- package/packages/mailx-send/cli-queue.js +0 -59
- package/packages/mailx-send/cli-queue.js.map +0 -1
- package/packages/mailx-send/cli-queue.ts +0 -62
- package/packages/mailx-send/cli-send.d.ts +0 -17
- package/packages/mailx-send/cli-send.d.ts.map +0 -1
- package/packages/mailx-send/cli-send.js +0 -75
- package/packages/mailx-send/cli-send.js.map +0 -1
- package/packages/mailx-send/cli-send.ts +0 -83
- package/packages/mailx-send/cli.d.ts +0 -22
- package/packages/mailx-send/cli.d.ts.map +0 -1
- package/packages/mailx-send/cli.js +0 -115
- package/packages/mailx-send/cli.js.map +0 -1
- package/packages/mailx-send/cli.ts +0 -126
- package/packages/mailx-send/index.d.ts +0 -77
- package/packages/mailx-send/index.d.ts.map +0 -1
- package/packages/mailx-send/index.js +0 -269
- package/packages/mailx-send/index.js.map +0 -1
- package/packages/mailx-send/index.ts +0 -338
- package/packages/mailx-send/mailsend/README.md +0 -133
- package/packages/mailx-send/mailsend/cli.d.ts +0 -12
- package/packages/mailx-send/mailsend/cli.d.ts.map +0 -1
- package/packages/mailx-send/mailsend/cli.js +0 -70
- package/packages/mailx-send/mailsend/cli.js.map +0 -1
- package/packages/mailx-send/mailsend/cli.ts +0 -81
- package/packages/mailx-send/mailsend/index.d.ts +0 -77
- package/packages/mailx-send/mailsend/index.d.ts.map +0 -1
- package/packages/mailx-send/mailsend/index.js +0 -264
- package/packages/mailx-send/mailsend/index.js.map +0 -1
- package/packages/mailx-send/mailsend/index.ts +0 -336
- package/packages/mailx-send/mailsend/package-lock.json +0 -65
- package/packages/mailx-send/mailsend/package.json +0 -26
- package/packages/mailx-send/mailsend/tsconfig.json +0 -21
- package/packages/mailx-send/package-lock.json +0 -65
- package/packages/mailx-send/package.json +0 -37
- package/packages/mailx-send/tsconfig.json +0 -21
- package/packages/mailx-server/.gitattributes +0 -10
- package/packages/mailx-server/index.d.ts +0 -8
- package/packages/mailx-server/index.d.ts.map +0 -1
- package/packages/mailx-server/index.js +0 -412
- package/packages/mailx-server/index.js.map +0 -1
- package/packages/mailx-server/index.ts +0 -445
- package/packages/mailx-server/package.json +0 -28
- package/packages/mailx-server/tsconfig.json +0 -9
- package/packages/mailx-server/tsconfig.tsbuildinfo +0 -1
- /package/packages/mailx-imap/{node_modules.npmglobalize-stash-40260 → node_modules.npmglobalize-stash-40004}/.package-lock.json +0 -0
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @bobfrankston/mailsend
|
|
3
|
-
* Queue-based mail sender. Each account has its own queue directory.
|
|
4
|
-
* Messages queued as .ltr (RFC 822) files, sent via SMTP with retry.
|
|
5
|
-
* Supports password and OAuth2 (Gmail) authentication.
|
|
6
|
-
*
|
|
7
|
-
* Directory structure:
|
|
8
|
-
* {baseDir}/{accountId}/queue/ — pending .ltr files
|
|
9
|
-
* {baseDir}/{accountId}/sent/ — sent messages (optional, YYYY/MM/DD)
|
|
10
|
-
* {baseDir}/{accountId}/fail/ — failed messages for retry
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import * as fs from "node:fs";
|
|
14
|
-
import * as path from "node:path";
|
|
15
|
-
import { createTransport, type Transporter } from "nodemailer";
|
|
16
|
-
import { encodeHeaderWord, encodeAddressHeader } from "@bobfrankston/mailx-types";
|
|
17
|
-
|
|
18
|
-
// ── Types ──
|
|
19
|
-
|
|
20
|
-
export interface SmtpConfig {
|
|
21
|
-
host: string;
|
|
22
|
-
port: number;
|
|
23
|
-
secure?: boolean;
|
|
24
|
-
auth: "password" | "oauth2";
|
|
25
|
-
user: string;
|
|
26
|
-
password?: string;
|
|
27
|
-
/** Default From address, e.g. "Bob Frankston <bob@iecc.com>" */
|
|
28
|
-
from?: string;
|
|
29
|
-
tokenProvider?: () => Promise<string>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface MailMessage {
|
|
33
|
-
from: string;
|
|
34
|
-
to: string[];
|
|
35
|
-
cc?: string[];
|
|
36
|
-
bcc?: string[];
|
|
37
|
-
subject: string;
|
|
38
|
-
html?: string;
|
|
39
|
-
text?: string;
|
|
40
|
-
inReplyTo?: string;
|
|
41
|
-
references?: string;
|
|
42
|
-
accountId?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface MailSendConfig {
|
|
46
|
-
/** Base directory for all queues */
|
|
47
|
-
baseDir: string;
|
|
48
|
-
/** SMTP configs keyed by account ID */
|
|
49
|
-
accounts: Record<string, SmtpConfig>;
|
|
50
|
-
/** Log sent messages to sent/ subdirectory */
|
|
51
|
-
logSent?: boolean;
|
|
52
|
-
/** Retry interval in ms (default: 5 minutes) */
|
|
53
|
-
retryIntervalMs?: number;
|
|
54
|
-
/** Default account ID */
|
|
55
|
-
defaultAccount?: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// ── File helpers ──
|
|
59
|
-
|
|
60
|
-
function generateFilename(): string {
|
|
61
|
-
const now = new Date();
|
|
62
|
-
const pad2 = (n: number) => String(n).padStart(2, "0");
|
|
63
|
-
const ts = `${now.getFullYear()}${pad2(now.getMonth() + 1)}${pad2(now.getDate())}_${pad2(now.getHours())}${pad2(now.getMinutes())}${pad2(now.getSeconds())}`;
|
|
64
|
-
const seq = String(Math.floor(Math.random() * 10000)).padStart(4, "0");
|
|
65
|
-
return `${ts}-${seq}.ltr`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function datePath(): string {
|
|
69
|
-
const dt = new Date();
|
|
70
|
-
const pad2 = (n: number) => String(n).padStart(2, "0");
|
|
71
|
-
return `${dt.getFullYear()}/${pad2(dt.getMonth() + 1)}/${pad2(dt.getDate())}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function moveToDateDir(filePath: string, destBase: string): void {
|
|
75
|
-
const dest = path.join(destBase, datePath());
|
|
76
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
77
|
-
fs.renameSync(filePath, path.join(dest, path.basename(filePath)));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function listLtr(dir: string): string[] {
|
|
81
|
-
if (!fs.existsSync(dir)) return [];
|
|
82
|
-
return fs.readdirSync(dir).filter(f => f.endsWith(".ltr")).sort();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function walkLtrCount(dir: string): number {
|
|
86
|
-
if (!fs.existsSync(dir)) return 0;
|
|
87
|
-
let count = 0;
|
|
88
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
89
|
-
if (entry.isDirectory()) count += walkLtrCount(path.join(dir, entry.name));
|
|
90
|
-
else if (entry.name.endsWith(".ltr")) count++;
|
|
91
|
-
}
|
|
92
|
-
return count;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function walkLtrFiles(dir: string): string[] {
|
|
96
|
-
if (!fs.existsSync(dir)) return [];
|
|
97
|
-
const files: string[] = [];
|
|
98
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
99
|
-
const full = path.join(dir, entry.name);
|
|
100
|
-
if (entry.isDirectory()) files.push(...walkLtrFiles(full));
|
|
101
|
-
else if (entry.name.endsWith(".ltr")) files.push(full);
|
|
102
|
-
}
|
|
103
|
-
return files;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// ── RFC 822 builder ──
|
|
107
|
-
|
|
108
|
-
export function buildRfc822(msg: MailMessage): string {
|
|
109
|
-
const lines: string[] = [];
|
|
110
|
-
// See the sibling copy in mailx-send/index.ts — RFC 2047 or the message
|
|
111
|
-
// goes out as EAI and bounces from non-SMTPUTF8 receivers.
|
|
112
|
-
lines.push(`From: ${encodeAddressHeader(msg.from)}`);
|
|
113
|
-
lines.push(`To: ${encodeAddressHeader(msg.to.join(", "))}`);
|
|
114
|
-
if (msg.cc?.length) lines.push(`Cc: ${encodeAddressHeader(msg.cc.join(", "))}`);
|
|
115
|
-
if (msg.bcc?.length) lines.push(`Bcc: ${encodeAddressHeader(msg.bcc.join(", "))}`);
|
|
116
|
-
lines.push(`Subject: ${encodeHeaderWord(msg.subject)}`);
|
|
117
|
-
lines.push(`Date: ${new Date().toUTCString()}`);
|
|
118
|
-
if (msg.inReplyTo) lines.push(`In-Reply-To: ${msg.inReplyTo}`);
|
|
119
|
-
if (msg.references) lines.push(`References: ${msg.references}`);
|
|
120
|
-
if (msg.accountId) lines.push(`X-MailSend-Account: ${msg.accountId}`);
|
|
121
|
-
lines.push(`MIME-Version: 1.0`);
|
|
122
|
-
|
|
123
|
-
if (msg.html) {
|
|
124
|
-
lines.push(`Content-Type: text/html; charset=UTF-8`);
|
|
125
|
-
lines.push(`Content-Transfer-Encoding: 8bit`);
|
|
126
|
-
lines.push("");
|
|
127
|
-
lines.push(msg.html);
|
|
128
|
-
} else {
|
|
129
|
-
lines.push(`Content-Type: text/plain; charset=UTF-8`);
|
|
130
|
-
lines.push(`Content-Transfer-Encoding: 8bit`);
|
|
131
|
-
lines.push("");
|
|
132
|
-
lines.push(msg.text || "");
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return lines.join("\r\n");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// ── Transport cache ──
|
|
139
|
-
|
|
140
|
-
const transports: Map<string, Transporter> = new Map();
|
|
141
|
-
|
|
142
|
-
function getTransport(config: SmtpConfig): Transporter {
|
|
143
|
-
const key = `${config.host}:${config.port}:${config.user}`;
|
|
144
|
-
let transport = transports.get(key);
|
|
145
|
-
if (!transport) {
|
|
146
|
-
const opts: any = {
|
|
147
|
-
host: config.host,
|
|
148
|
-
port: config.port,
|
|
149
|
-
secure: config.secure ?? (config.port === 465),
|
|
150
|
-
tls: { rejectUnauthorized: false },
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
if (config.auth === "password") {
|
|
154
|
-
opts.auth = { user: config.user, pass: config.password };
|
|
155
|
-
} else if (config.auth === "oauth2") {
|
|
156
|
-
opts.auth = { type: "OAuth2", user: config.user };
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
transport = createTransport(opts);
|
|
160
|
-
transports.set(key, transport);
|
|
161
|
-
}
|
|
162
|
-
return transport;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ── MailSender ──
|
|
166
|
-
|
|
167
|
-
let singleton: MailSender | null = null;
|
|
168
|
-
|
|
169
|
-
export class MailSender {
|
|
170
|
-
private config: MailSendConfig;
|
|
171
|
-
private processing = false;
|
|
172
|
-
private retryTimer: ReturnType<typeof setInterval> | null = null;
|
|
173
|
-
|
|
174
|
-
constructor(config: MailSendConfig) {
|
|
175
|
-
this.config = config;
|
|
176
|
-
// Ensure base directory exists
|
|
177
|
-
fs.mkdirSync(config.baseDir, { recursive: true });
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
private accountDir(accountId: string): string {
|
|
181
|
-
return path.join(this.config.baseDir, accountId);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
private queueDir(accountId: string): string {
|
|
185
|
-
const dir = path.join(this.accountDir(accountId), "queue");
|
|
186
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
187
|
-
return dir;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
private sentDir(accountId: string): string {
|
|
191
|
-
return path.join(this.accountDir(accountId), "sent");
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
private failDir(accountId: string): string {
|
|
195
|
-
const dir = path.join(this.accountDir(accountId), "fail");
|
|
196
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
197
|
-
return dir;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/** Queue a message. Returns the filename. */
|
|
201
|
-
queueMessage(msg: MailMessage): string {
|
|
202
|
-
const accountId = msg.accountId || this.config.defaultAccount;
|
|
203
|
-
if (!accountId) throw new Error("No accountId and no defaultAccount configured");
|
|
204
|
-
msg.accountId = accountId;
|
|
205
|
-
|
|
206
|
-
const content = buildRfc822(msg);
|
|
207
|
-
const filename = generateFilename();
|
|
208
|
-
fs.writeFileSync(path.join(this.queueDir(accountId), filename), content);
|
|
209
|
-
|
|
210
|
-
// Process immediately (non-blocking)
|
|
211
|
-
this.processQueue(accountId).catch(e =>
|
|
212
|
-
console.error(`[mailsend] Process error: ${e.message}`)
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
return filename;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/** Process pending messages for one account */
|
|
219
|
-
async processQueue(accountId: string): Promise<void> {
|
|
220
|
-
if (this.processing) return;
|
|
221
|
-
this.processing = true;
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
const smtpConfig = this.config.accounts[accountId];
|
|
225
|
-
if (!smtpConfig) {
|
|
226
|
-
console.error(`[mailsend] No SMTP config for: ${accountId}`);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const files = listLtr(this.queueDir(accountId));
|
|
231
|
-
for (const file of files) {
|
|
232
|
-
await this.sendFile(path.join(this.queueDir(accountId), file), accountId, smtpConfig);
|
|
233
|
-
}
|
|
234
|
-
} finally {
|
|
235
|
-
this.processing = false;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/** Process all account queues */
|
|
240
|
-
async processAllQueues(): Promise<void> {
|
|
241
|
-
for (const accountId of Object.keys(this.config.accounts)) {
|
|
242
|
-
await this.processQueue(accountId);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
private async sendFile(filePath: string, accountId: string, smtpConfig: SmtpConfig): Promise<boolean> {
|
|
247
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
const transport = getTransport(smtpConfig);
|
|
251
|
-
|
|
252
|
-
if (smtpConfig.auth === "oauth2" && smtpConfig.tokenProvider) {
|
|
253
|
-
const token = await smtpConfig.tokenProvider();
|
|
254
|
-
(transport as any).options.auth.accessToken = token;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const result = await transport.sendMail({ raw: content });
|
|
258
|
-
|
|
259
|
-
if (result.rejected?.length > 0) {
|
|
260
|
-
console.error(`[mailsend] Rejected: ${result.rejected.join(", ")} — ${path.basename(filePath)}`);
|
|
261
|
-
moveToDateDir(filePath, this.failDir(accountId));
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
console.log(`[mailsend] Sent: ${path.basename(filePath)} → ${result.accepted?.join(", ")} (${result.messageId})`);
|
|
266
|
-
|
|
267
|
-
if (this.config.logSent) {
|
|
268
|
-
moveToDateDir(filePath, this.sentDir(accountId));
|
|
269
|
-
} else {
|
|
270
|
-
fs.unlinkSync(filePath);
|
|
271
|
-
}
|
|
272
|
-
return true;
|
|
273
|
-
} catch (e: any) {
|
|
274
|
-
console.error(`[mailsend] Error: ${path.basename(filePath)}: ${e.message}`);
|
|
275
|
-
moveToDateDir(filePath, this.failDir(accountId));
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/** Start background worker — retries failed, processes queues */
|
|
281
|
-
startWorker(): void {
|
|
282
|
-
if (this.retryTimer) return;
|
|
283
|
-
const interval = this.config.retryIntervalMs || 300000;
|
|
284
|
-
|
|
285
|
-
this.retryTimer = setInterval(async () => {
|
|
286
|
-
for (const accountId of Object.keys(this.config.accounts)) {
|
|
287
|
-
this.retryFailed(accountId);
|
|
288
|
-
}
|
|
289
|
-
await this.processAllQueues();
|
|
290
|
-
}, interval);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
private retryFailed(accountId: string): void {
|
|
294
|
-
const failFiles = walkLtrFiles(this.failDir(accountId));
|
|
295
|
-
const queueDir = this.queueDir(accountId);
|
|
296
|
-
for (const file of failFiles) {
|
|
297
|
-
fs.renameSync(file, path.join(queueDir, path.basename(file)));
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
stopWorker(): void {
|
|
302
|
-
if (this.retryTimer) {
|
|
303
|
-
clearInterval(this.retryTimer);
|
|
304
|
-
this.retryTimer = null;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/** Get queue status per account */
|
|
309
|
-
getStatus(): Record<string, { pending: number; failed: number }> {
|
|
310
|
-
const result: Record<string, { pending: number; failed: number }> = {};
|
|
311
|
-
for (const accountId of Object.keys(this.config.accounts)) {
|
|
312
|
-
result[accountId] = {
|
|
313
|
-
pending: listLtr(this.queueDir(accountId)).length,
|
|
314
|
-
failed: walkLtrCount(this.failDir(accountId)),
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
return result;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// ── Singleton API ──
|
|
322
|
-
|
|
323
|
-
export function initMailSend(config: MailSendConfig): MailSender {
|
|
324
|
-
singleton = new MailSender(config);
|
|
325
|
-
singleton.startWorker();
|
|
326
|
-
return singleton;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
export function getMailSender(): MailSender | null {
|
|
330
|
-
return singleton;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export function queueMessage(msg: MailMessage): string {
|
|
334
|
-
if (!singleton) throw new Error("mailsend not initialized — call initMailSend() first");
|
|
335
|
-
return singleton.queueMessage(msg);
|
|
336
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bobfrankston/mailsend",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"lockfileVersion": 3,
|
|
5
|
-
"requires": true,
|
|
6
|
-
"packages": {
|
|
7
|
-
"": {
|
|
8
|
-
"name": "@bobfrankston/mailsend",
|
|
9
|
-
"version": "0.1.0",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@bobfrankston/oauthsupport": "file:../../projects/oauth/oauthsupport",
|
|
13
|
-
"nodemailer": "^7.0.0"
|
|
14
|
-
},
|
|
15
|
-
"bin": {
|
|
16
|
-
"mailsend": "cli.js"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@types/node": "^22.0.0",
|
|
20
|
-
"@types/nodemailer": "^6.4.0"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"../../projects/oauth/oauthsupport": {},
|
|
24
|
-
"node_modules/@bobfrankston/oauthsupport": {
|
|
25
|
-
"resolved": "../../projects/oauth/oauthsupport",
|
|
26
|
-
"link": true
|
|
27
|
-
},
|
|
28
|
-
"node_modules/@types/node": {
|
|
29
|
-
"version": "22.19.15",
|
|
30
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.15.tgz",
|
|
31
|
-
"integrity": "sha512-F0R/h2+dsy5wJAUe3tAU6oqa2qbWY5TpNfL/RGmo1y38hiyO1w3x2jPtt76wmuaJI4DQnOBu21cNXQ2STIUUWg==",
|
|
32
|
-
"dev": true,
|
|
33
|
-
"license": "MIT",
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"undici-types": "~6.21.0"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"node_modules/@types/nodemailer": {
|
|
39
|
-
"version": "6.4.23",
|
|
40
|
-
"resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-6.4.23.tgz",
|
|
41
|
-
"integrity": "sha512-aFV3/NsYFLSx9mbb5gtirBSXJnAlrusoKNuPbxsASWc7vrKLmIrTQRpdcxNcSFL3VW2A2XpeLEavwb2qMi6nlQ==",
|
|
42
|
-
"dev": true,
|
|
43
|
-
"license": "MIT",
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"@types/node": "*"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"node_modules/nodemailer": {
|
|
49
|
-
"version": "7.0.13",
|
|
50
|
-
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.13.tgz",
|
|
51
|
-
"integrity": "sha512-PNDFSJdP+KFgdsG3ZzMXCgquO7I6McjY2vlqILjtJd0hy8wEvtugS9xKRF2NWlPNGxvLCXlTNIae4serI7dinw==",
|
|
52
|
-
"license": "MIT-0",
|
|
53
|
-
"engines": {
|
|
54
|
-
"node": ">=6.0.0"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"node_modules/undici-types": {
|
|
58
|
-
"version": "6.21.0",
|
|
59
|
-
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
|
60
|
-
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
|
61
|
-
"dev": true,
|
|
62
|
-
"license": "MIT"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bobfrankston/mailsend",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"description": "Queue-based mail sender with SMTP and OAuth2 support",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"types": "index.d.ts",
|
|
8
|
-
"bin": {
|
|
9
|
-
"mailsend": "cli.js"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"release": "npmglobalize"
|
|
14
|
-
},
|
|
15
|
-
"keywords": ["email", "smtp", "queue", "oauth2", "gmail"],
|
|
16
|
-
"author": "Bob Frankston",
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"nodemailer": "^7.0.0",
|
|
20
|
-
"@bobfrankston/oauthsupport": "file:../../projects/oauth/oauthsupport"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@types/nodemailer": "^6.4.0",
|
|
24
|
-
"@types/node": "^22.0.0"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"allowSyntheticDefaultImports": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"strictNullChecks": false,
|
|
10
|
-
"noImplicitAny": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"declarationMap": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"outDir": ".",
|
|
16
|
-
"rootDir": ".",
|
|
17
|
-
"newLine": "lf"
|
|
18
|
-
},
|
|
19
|
-
"include": ["*.ts"],
|
|
20
|
-
"exclude": ["node_modules", "prev", "cruft"]
|
|
21
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bobfrankston/mailsend",
|
|
3
|
-
"version": "0.1.1",
|
|
4
|
-
"lockfileVersion": 3,
|
|
5
|
-
"requires": true,
|
|
6
|
-
"packages": {
|
|
7
|
-
"": {
|
|
8
|
-
"name": "@bobfrankston/mailsend",
|
|
9
|
-
"version": "0.1.1",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@bobfrankston/oauthsupport": "file:../../projects/oauth/oauthsupport",
|
|
13
|
-
"nodemailer": "^7.0.0"
|
|
14
|
-
},
|
|
15
|
-
"bin": {
|
|
16
|
-
"mailsend": "cli.js"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@types/node": "^22.0.0",
|
|
20
|
-
"@types/nodemailer": "^6.4.0"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"../../projects/oauth/oauthsupport": {},
|
|
24
|
-
"node_modules/@bobfrankston/oauthsupport": {
|
|
25
|
-
"resolved": "../../projects/oauth/oauthsupport",
|
|
26
|
-
"link": true
|
|
27
|
-
},
|
|
28
|
-
"node_modules/@types/node": {
|
|
29
|
-
"version": "22.19.15",
|
|
30
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.15.tgz",
|
|
31
|
-
"integrity": "sha512-F0R/h2+dsy5wJAUe3tAU6oqa2qbWY5TpNfL/RGmo1y38hiyO1w3x2jPtt76wmuaJI4DQnOBu21cNXQ2STIUUWg==",
|
|
32
|
-
"dev": true,
|
|
33
|
-
"license": "MIT",
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"undici-types": "~6.21.0"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"node_modules/@types/nodemailer": {
|
|
39
|
-
"version": "6.4.23",
|
|
40
|
-
"resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-6.4.23.tgz",
|
|
41
|
-
"integrity": "sha512-aFV3/NsYFLSx9mbb5gtirBSXJnAlrusoKNuPbxsASWc7vrKLmIrTQRpdcxNcSFL3VW2A2XpeLEavwb2qMi6nlQ==",
|
|
42
|
-
"dev": true,
|
|
43
|
-
"license": "MIT",
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"@types/node": "*"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"node_modules/nodemailer": {
|
|
49
|
-
"version": "7.0.13",
|
|
50
|
-
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.13.tgz",
|
|
51
|
-
"integrity": "sha512-PNDFSJdP+KFgdsG3ZzMXCgquO7I6McjY2vlqILjtJd0hy8wEvtugS9xKRF2NWlPNGxvLCXlTNIae4serI7dinw==",
|
|
52
|
-
"license": "MIT-0",
|
|
53
|
-
"engines": {
|
|
54
|
-
"node": ">=6.0.0"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"node_modules/undici-types": {
|
|
58
|
-
"version": "6.21.0",
|
|
59
|
-
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
|
60
|
-
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
|
61
|
-
"dev": true,
|
|
62
|
-
"license": "MIT"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bobfrankston/mailx-send",
|
|
3
|
-
"version": "0.1.2",
|
|
4
|
-
"description": "Queue-based mail sender with SMTP and OAuth2 support",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"types": "index.d.ts",
|
|
8
|
-
"bin": {
|
|
9
|
-
"mailsend": "cli-send.js",
|
|
10
|
-
"mailq": "cli-queue.js"
|
|
11
|
-
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "tsc",
|
|
14
|
-
"release": "npmglobalize"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"email",
|
|
18
|
-
"smtp",
|
|
19
|
-
"queue",
|
|
20
|
-
"oauth2",
|
|
21
|
-
"gmail"
|
|
22
|
-
],
|
|
23
|
-
"author": "Bob Frankston",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"nodemailer": "^7.0.0",
|
|
27
|
-
"@bobfrankston/oauthsupport": "file:../../../../../projects/oauth/oauthsupport"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@types/nodemailer": "^6.4.0",
|
|
31
|
-
"@types/node": "^22.0.0"
|
|
32
|
-
},
|
|
33
|
-
"repository": {
|
|
34
|
-
"type": "git",
|
|
35
|
-
"url": "https://github.com/BobFrankston/mailx-send.git"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"allowSyntheticDefaultImports": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"strictNullChecks": false,
|
|
10
|
-
"noImplicitAny": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"declarationMap": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"outDir": ".",
|
|
16
|
-
"rootDir": ".",
|
|
17
|
-
"newLine": "lf"
|
|
18
|
-
},
|
|
19
|
-
"include": ["*.ts"],
|
|
20
|
-
"exclude": ["node_modules", "prev", "cruft"]
|
|
21
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @bobfrankston/mailx-server
|
|
3
|
-
* Express server: serves client, mounts API, manages WebSocket push.
|
|
4
|
-
*/
|
|
5
|
-
declare const app: import("express-serve-static-core").Express;
|
|
6
|
-
declare function start(): Promise<void>;
|
|
7
|
-
export { app, start };
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqEH,QAAA,MAAM,GAAG,6CAAY,CAAC;AAiPtB,iBAAe,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CA0FpC;AAyCD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC"}
|