@bobfrankston/rmfmail 1.0.467
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 +429 -0
- package/bin/build-icon-ico.js +283 -0
- package/bin/lean-accounts.js +172 -0
- package/bin/mailx.js +1580 -0
- package/bin/mailx.js.map +1 -0
- package/bin/mailx.ts +1549 -0
- package/bin/postinstall.js +39 -0
- package/bin/postinstall.js.map +1 -0
- package/bin/postinstall.ts +41 -0
- package/bin/tsconfig.json +10 -0
- package/client/.gitattributes +10 -0
- package/client/.msger-window.json +1 -0
- package/client/android.html +226 -0
- package/client/app.js +3400 -0
- package/client/app.js.map +1 -0
- package/client/app.ts +3190 -0
- package/client/components/address-book.js +199 -0
- package/client/components/address-book.js.map +1 -0
- package/client/components/address-book.ts +204 -0
- package/client/components/alarms.js +299 -0
- package/client/components/alarms.js.map +1 -0
- package/client/components/alarms.ts +276 -0
- package/client/components/calendar-sidebar.js +508 -0
- package/client/components/calendar-sidebar.js.map +1 -0
- package/client/components/calendar-sidebar.ts +474 -0
- package/client/components/calendar.js +217 -0
- package/client/components/calendar.js.map +1 -0
- package/client/components/calendar.ts +211 -0
- package/client/components/context-menu.js +80 -0
- package/client/components/context-menu.js.map +1 -0
- package/client/components/context-menu.ts +95 -0
- package/client/components/folder-picker.js +119 -0
- package/client/components/folder-picker.js.map +1 -0
- package/client/components/folder-picker.ts +127 -0
- package/client/components/folder-tree.js +1093 -0
- package/client/components/folder-tree.js.map +1 -0
- package/client/components/folder-tree.ts +1069 -0
- package/client/components/message-list.js +1140 -0
- package/client/components/message-list.js.map +1 -0
- package/client/components/message-list.ts +1129 -0
- package/client/components/message-viewer.js +1291 -0
- package/client/components/message-viewer.js.map +1 -0
- package/client/components/message-viewer.ts +1257 -0
- package/client/components/outbox-view.js +104 -0
- package/client/components/outbox-view.js.map +1 -0
- package/client/components/outbox-view.ts +102 -0
- package/client/components/tasks.js +261 -0
- package/client/components/tasks.js.map +1 -0
- package/client/components/tasks.ts +234 -0
- package/client/compose/compose.css +560 -0
- package/client/compose/compose.html +52 -0
- package/client/compose/compose.js +1289 -0
- package/client/compose/compose.js.map +1 -0
- package/client/compose/compose.ts +1231 -0
- package/client/compose/editor.js +616 -0
- package/client/compose/editor.js.map +1 -0
- package/client/compose/editor.ts +599 -0
- package/client/compose/ghost-text.js +122 -0
- package/client/compose/ghost-text.js.map +1 -0
- package/client/compose/ghost-text.ts +140 -0
- package/client/favicon.svg +11 -0
- package/client/icon.ico +0 -0
- package/client/icon.png +0 -0
- package/client/index.html +230 -0
- package/client/lib/android-bootstrap.js +9 -0
- package/client/lib/android-bootstrap.js.map +1 -0
- package/client/lib/android-bootstrap.ts +9 -0
- package/client/lib/api-client.js +378 -0
- package/client/lib/api-client.js.map +1 -0
- package/client/lib/api-client.ts +439 -0
- package/client/lib/local-service.js +603 -0
- package/client/lib/local-service.js.map +1 -0
- package/client/lib/local-service.ts +646 -0
- package/client/lib/local-store.js +214 -0
- package/client/lib/local-store.js.map +1 -0
- package/client/lib/local-store.ts +283 -0
- package/client/lib/mailxapi.js +304 -0
- package/client/lib/message-state.js +132 -0
- package/client/lib/message-state.js.map +1 -0
- package/client/lib/message-state.ts +160 -0
- package/client/package.json +16 -0
- package/client/styles/components.css +2049 -0
- package/client/styles/layout.css +332 -0
- package/client/styles/variables.css +85 -0
- package/client/tsconfig.json +19 -0
- package/package.json +124 -0
- package/packages/mailx-api/.gitattributes +10 -0
- package/packages/mailx-api/index.d.ts +10 -0
- package/packages/mailx-api/index.d.ts.map +1 -0
- package/packages/mailx-api/index.js +322 -0
- package/packages/mailx-api/index.js.map +1 -0
- package/packages/mailx-api/index.ts +283 -0
- package/packages/mailx-api/package.json +27 -0
- package/packages/mailx-api/tsconfig.json +9 -0
- package/packages/mailx-api/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-compose/.gitattributes +10 -0
- package/packages/mailx-compose/index.d.ts +21 -0
- package/packages/mailx-compose/index.d.ts.map +1 -0
- package/packages/mailx-compose/index.js +61 -0
- package/packages/mailx-compose/index.js.map +1 -0
- package/packages/mailx-compose/index.ts +85 -0
- package/packages/mailx-compose/package.json +18 -0
- package/packages/mailx-compose/tsconfig.json +9 -0
- package/packages/mailx-core/index.d.ts +139 -0
- package/packages/mailx-core/index.d.ts.map +1 -0
- package/packages/mailx-core/index.js +403 -0
- package/packages/mailx-core/index.js.map +1 -0
- package/packages/mailx-core/index.ts +424 -0
- package/packages/mailx-core/ipc.d.ts +13 -0
- package/packages/mailx-core/ipc.d.ts.map +1 -0
- package/packages/mailx-core/ipc.js +56 -0
- package/packages/mailx-core/ipc.js.map +1 -0
- package/packages/mailx-core/ipc.ts +62 -0
- package/packages/mailx-core/package.json +18 -0
- package/packages/mailx-core/tsconfig.json +9 -0
- package/packages/mailx-host/.gitattributes +10 -0
- package/packages/mailx-host/index.d.ts +21 -0
- package/packages/mailx-host/index.d.ts.map +1 -0
- package/packages/mailx-host/index.js +29 -0
- package/packages/mailx-host/index.js.map +1 -0
- package/packages/mailx-host/index.ts +38 -0
- package/packages/mailx-host/package.json +23 -0
- package/packages/mailx-host/tsconfig.json +9 -0
- package/packages/mailx-host/types-shim.d.ts +14 -0
- package/packages/mailx-imap/.gitattributes +10 -0
- package/packages/mailx-imap/index.d.ts +442 -0
- package/packages/mailx-imap/index.d.ts.map +1 -0
- package/packages/mailx-imap/index.js +3684 -0
- package/packages/mailx-imap/index.js.map +1 -0
- package/packages/mailx-imap/index.ts +3652 -0
- package/packages/mailx-imap/package-lock.json +131 -0
- package/packages/mailx-imap/package.json +28 -0
- package/packages/mailx-imap/providers/gmail-api.d.ts +8 -0
- package/packages/mailx-imap/providers/gmail-api.d.ts.map +1 -0
- package/packages/mailx-imap/providers/gmail-api.js +8 -0
- package/packages/mailx-imap/providers/gmail-api.js.map +1 -0
- package/packages/mailx-imap/providers/gmail-api.ts +8 -0
- package/packages/mailx-imap/providers/outlook-api.ts +7 -0
- package/packages/mailx-imap/providers/types.d.ts +9 -0
- package/packages/mailx-imap/providers/types.d.ts.map +1 -0
- package/packages/mailx-imap/providers/types.js +9 -0
- package/packages/mailx-imap/providers/types.js.map +1 -0
- package/packages/mailx-imap/providers/types.ts +9 -0
- package/packages/mailx-imap/tsconfig.json +9 -0
- package/packages/mailx-imap/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-send/.gitattributes +10 -0
- package/packages/mailx-send/README.md +217 -0
- package/packages/mailx-send/cli-queue.d.ts +11 -0
- package/packages/mailx-send/cli-queue.d.ts.map +1 -0
- package/packages/mailx-send/cli-queue.js +59 -0
- package/packages/mailx-send/cli-queue.js.map +1 -0
- package/packages/mailx-send/cli-queue.ts +62 -0
- package/packages/mailx-send/cli-send.d.ts +17 -0
- package/packages/mailx-send/cli-send.d.ts.map +1 -0
- package/packages/mailx-send/cli-send.js +75 -0
- package/packages/mailx-send/cli-send.js.map +1 -0
- package/packages/mailx-send/cli-send.ts +83 -0
- package/packages/mailx-send/cli.d.ts +22 -0
- package/packages/mailx-send/cli.d.ts.map +1 -0
- package/packages/mailx-send/cli.js +115 -0
- package/packages/mailx-send/cli.js.map +1 -0
- package/packages/mailx-send/cli.ts +126 -0
- package/packages/mailx-send/index.d.ts +77 -0
- package/packages/mailx-send/index.d.ts.map +1 -0
- package/packages/mailx-send/index.js +264 -0
- package/packages/mailx-send/index.js.map +1 -0
- package/packages/mailx-send/index.ts +333 -0
- package/packages/mailx-send/mailsend/README.md +133 -0
- package/packages/mailx-send/mailsend/cli.d.ts +12 -0
- package/packages/mailx-send/mailsend/cli.d.ts.map +1 -0
- package/packages/mailx-send/mailsend/cli.js +70 -0
- package/packages/mailx-send/mailsend/cli.js.map +1 -0
- package/packages/mailx-send/mailsend/cli.ts +81 -0
- package/packages/mailx-send/mailsend/index.d.ts +77 -0
- package/packages/mailx-send/mailsend/index.d.ts.map +1 -0
- package/packages/mailx-send/mailsend/index.js +264 -0
- package/packages/mailx-send/mailsend/index.js.map +1 -0
- package/packages/mailx-send/mailsend/index.ts +333 -0
- package/packages/mailx-send/mailsend/package-lock.json +65 -0
- package/packages/mailx-send/mailsend/package.json +26 -0
- package/packages/mailx-send/mailsend/tsconfig.json +21 -0
- package/packages/mailx-send/package-lock.json +65 -0
- package/packages/mailx-send/package.json +37 -0
- package/packages/mailx-send/tsconfig.json +21 -0
- package/packages/mailx-server/.gitattributes +10 -0
- package/packages/mailx-server/index.d.ts +8 -0
- package/packages/mailx-server/index.d.ts.map +1 -0
- package/packages/mailx-server/index.js +397 -0
- package/packages/mailx-server/index.js.map +1 -0
- package/packages/mailx-server/index.ts +429 -0
- package/packages/mailx-server/package.json +28 -0
- package/packages/mailx-server/tsconfig.json +9 -0
- package/packages/mailx-server/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-service/google-sync.d.ts +96 -0
- package/packages/mailx-service/google-sync.d.ts.map +1 -0
- package/packages/mailx-service/google-sync.js +153 -0
- package/packages/mailx-service/google-sync.js.map +1 -0
- package/packages/mailx-service/google-sync.ts +238 -0
- package/packages/mailx-service/index.d.ts +366 -0
- package/packages/mailx-service/index.d.ts.map +1 -0
- package/packages/mailx-service/index.js +2589 -0
- package/packages/mailx-service/index.js.map +1 -0
- package/packages/mailx-service/index.ts +2512 -0
- package/packages/mailx-service/jsonrpc.d.ts +25 -0
- package/packages/mailx-service/jsonrpc.d.ts.map +1 -0
- package/packages/mailx-service/jsonrpc.js +238 -0
- package/packages/mailx-service/jsonrpc.js.map +1 -0
- package/packages/mailx-service/jsonrpc.ts +268 -0
- package/packages/mailx-service/package.json +22 -0
- package/packages/mailx-service/tsconfig.json +9 -0
- package/packages/mailx-settings/.gitattributes +10 -0
- package/packages/mailx-settings/cloud.d.ts +47 -0
- package/packages/mailx-settings/cloud.d.ts.map +1 -0
- package/packages/mailx-settings/cloud.js +408 -0
- package/packages/mailx-settings/cloud.js.map +1 -0
- package/packages/mailx-settings/cloud.ts +393 -0
- package/packages/mailx-settings/index.d.ts +140 -0
- package/packages/mailx-settings/index.d.ts.map +1 -0
- package/packages/mailx-settings/index.js +872 -0
- package/packages/mailx-settings/index.js.map +1 -0
- package/packages/mailx-settings/index.ts +908 -0
- package/packages/mailx-settings/package.json +20 -0
- package/packages/mailx-settings/tsconfig.json +9 -0
- package/packages/mailx-settings/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-store/.gitattributes +10 -0
- package/packages/mailx-store/db.d.ts +346 -0
- package/packages/mailx-store/db.d.ts.map +1 -0
- package/packages/mailx-store/db.js +1796 -0
- package/packages/mailx-store/db.js.map +1 -0
- package/packages/mailx-store/db.ts +2007 -0
- package/packages/mailx-store/file-store.d.ts +36 -0
- package/packages/mailx-store/file-store.d.ts.map +1 -0
- package/packages/mailx-store/file-store.js +80 -0
- package/packages/mailx-store/file-store.js.map +1 -0
- package/packages/mailx-store/file-store.ts +82 -0
- package/packages/mailx-store/index.d.ts +7 -0
- package/packages/mailx-store/index.d.ts.map +1 -0
- package/packages/mailx-store/index.js +7 -0
- package/packages/mailx-store/index.js.map +1 -0
- package/packages/mailx-store/index.ts +7 -0
- package/packages/mailx-store/package.json +19 -0
- package/packages/mailx-store/tsconfig.json +9 -0
- package/packages/mailx-store/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-store-web/android-bootstrap.d.ts +16 -0
- package/packages/mailx-store-web/android-bootstrap.d.ts.map +1 -0
- package/packages/mailx-store-web/android-bootstrap.js +1247 -0
- package/packages/mailx-store-web/android-bootstrap.js.map +1 -0
- package/packages/mailx-store-web/android-bootstrap.ts +1262 -0
- package/packages/mailx-store-web/db.d.ts +132 -0
- package/packages/mailx-store-web/db.d.ts.map +1 -0
- package/packages/mailx-store-web/db.js +642 -0
- package/packages/mailx-store-web/db.js.map +1 -0
- package/packages/mailx-store-web/db.ts +756 -0
- package/packages/mailx-store-web/gmail-api-web.d.ts +11 -0
- package/packages/mailx-store-web/gmail-api-web.d.ts.map +1 -0
- package/packages/mailx-store-web/gmail-api-web.js +11 -0
- package/packages/mailx-store-web/gmail-api-web.js.map +1 -0
- package/packages/mailx-store-web/gmail-api-web.ts +11 -0
- package/packages/mailx-store-web/imap-web-provider.d.ts +33 -0
- package/packages/mailx-store-web/imap-web-provider.d.ts.map +1 -0
- package/packages/mailx-store-web/imap-web-provider.js +140 -0
- package/packages/mailx-store-web/imap-web-provider.js.map +1 -0
- package/packages/mailx-store-web/imap-web-provider.ts +156 -0
- package/packages/mailx-store-web/index.d.ts +10 -0
- package/packages/mailx-store-web/index.d.ts.map +1 -0
- package/packages/mailx-store-web/index.js +10 -0
- package/packages/mailx-store-web/index.js.map +1 -0
- package/packages/mailx-store-web/index.ts +10 -0
- package/packages/mailx-store-web/main-thread-host.d.ts +15 -0
- package/packages/mailx-store-web/main-thread-host.d.ts.map +1 -0
- package/packages/mailx-store-web/main-thread-host.js +292 -0
- package/packages/mailx-store-web/main-thread-host.js.map +1 -0
- package/packages/mailx-store-web/main-thread-host.ts +322 -0
- package/packages/mailx-store-web/package.json +23 -0
- package/packages/mailx-store-web/provider-types.d.ts +7 -0
- package/packages/mailx-store-web/provider-types.d.ts.map +1 -0
- package/packages/mailx-store-web/provider-types.js +7 -0
- package/packages/mailx-store-web/provider-types.js.map +1 -0
- package/packages/mailx-store-web/provider-types.ts +7 -0
- package/packages/mailx-store-web/sql-wasm-esm.js +10 -0
- package/packages/mailx-store-web/sql.js.d.ts +29 -0
- package/packages/mailx-store-web/sync-manager.d.ts +68 -0
- package/packages/mailx-store-web/sync-manager.d.ts.map +1 -0
- package/packages/mailx-store-web/sync-manager.js +506 -0
- package/packages/mailx-store-web/sync-manager.js.map +1 -0
- package/packages/mailx-store-web/sync-manager.ts +508 -0
- package/packages/mailx-store-web/tsconfig.json +10 -0
- package/packages/mailx-store-web/web-jsonrpc.d.ts +20 -0
- package/packages/mailx-store-web/web-jsonrpc.d.ts.map +1 -0
- package/packages/mailx-store-web/web-jsonrpc.js +102 -0
- package/packages/mailx-store-web/web-jsonrpc.js.map +1 -0
- package/packages/mailx-store-web/web-jsonrpc.ts +116 -0
- package/packages/mailx-store-web/web-message-store.d.ts +16 -0
- package/packages/mailx-store-web/web-message-store.d.ts.map +1 -0
- package/packages/mailx-store-web/web-message-store.js +89 -0
- package/packages/mailx-store-web/web-message-store.js.map +1 -0
- package/packages/mailx-store-web/web-message-store.ts +97 -0
- package/packages/mailx-store-web/web-service.d.ts +111 -0
- package/packages/mailx-store-web/web-service.d.ts.map +1 -0
- package/packages/mailx-store-web/web-service.js +542 -0
- package/packages/mailx-store-web/web-service.js.map +1 -0
- package/packages/mailx-store-web/web-service.ts +616 -0
- package/packages/mailx-store-web/web-settings.d.ts +83 -0
- package/packages/mailx-store-web/web-settings.d.ts.map +1 -0
- package/packages/mailx-store-web/web-settings.js +491 -0
- package/packages/mailx-store-web/web-settings.js.map +1 -0
- package/packages/mailx-store-web/web-settings.ts +522 -0
- package/packages/mailx-store-web/worker-bundle.js +6838 -0
- package/packages/mailx-store-web/worker-entry.d.ts +8 -0
- package/packages/mailx-store-web/worker-entry.d.ts.map +1 -0
- package/packages/mailx-store-web/worker-entry.js +187 -0
- package/packages/mailx-store-web/worker-entry.js.map +1 -0
- package/packages/mailx-store-web/worker-entry.ts +215 -0
- package/packages/mailx-store-web/worker-tcp-transport.d.ts +28 -0
- package/packages/mailx-store-web/worker-tcp-transport.d.ts.map +1 -0
- package/packages/mailx-store-web/worker-tcp-transport.js +98 -0
- package/packages/mailx-store-web/worker-tcp-transport.js.map +1 -0
- package/packages/mailx-store-web/worker-tcp-transport.ts +101 -0
- package/packages/mailx-types/.gitattributes +10 -0
- package/packages/mailx-types/index.d.ts +319 -0
- package/packages/mailx-types/index.d.ts.map +1 -0
- package/packages/mailx-types/index.js +243 -0
- package/packages/mailx-types/index.js.map +1 -0
- package/packages/mailx-types/index.ts +498 -0
- package/packages/mailx-types/package.json +16 -0
- package/packages/mailx-types/tsconfig.json +9 -0
- package/packages/mailx-types/tsconfig.tsbuildinfo +1 -0
- package/todo.json +13 -0
- package/tsconfig.base.json +31 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* mailsend — create and send an email message.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* mailsend --to addr --subject "text" --body "text"
|
|
7
|
+
* mailsend -q gmail --from "Bob <bob@gmail.com>" --to addr --subject "text"
|
|
8
|
+
* mailsend --json message.json Read message from JSON file
|
|
9
|
+
* echo '{"to":["a@b.com"],...}' | mailsend --json - Read from stdin
|
|
10
|
+
*
|
|
11
|
+
* JSON format:
|
|
12
|
+
* { "to": ["addr"], "cc": ["addr"], "from": "Name <addr>",
|
|
13
|
+
* "subject": "text", "text": "body", "html": "<p>body</p>",
|
|
14
|
+
* "accountId": "iecc" }
|
|
15
|
+
*/
|
|
16
|
+
import * as fs from "node:fs";
|
|
17
|
+
import { initMailSend, queueMessage } from "./index.js";
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
function getArg(name) {
|
|
20
|
+
const shorts = { q: "queue" };
|
|
21
|
+
const longIdx = args.indexOf(`--${name}`);
|
|
22
|
+
const shortKey = Object.entries(shorts).find(([, v]) => v === name)?.[0];
|
|
23
|
+
const shortIdx = shortKey ? args.indexOf(`-${shortKey}`) : -1;
|
|
24
|
+
const i = Math.max(longIdx, shortIdx);
|
|
25
|
+
if (i === -1 || i + 1 >= args.length)
|
|
26
|
+
return undefined;
|
|
27
|
+
return args[i + 1];
|
|
28
|
+
}
|
|
29
|
+
const configPath = getArg("config") || "mailsend.json";
|
|
30
|
+
if (!fs.existsSync(configPath)) {
|
|
31
|
+
console.error(`Config file not found: ${configPath}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
35
|
+
const sender = initMailSend(config);
|
|
36
|
+
const accountId = getArg("queue") || config.defaultAccount || "";
|
|
37
|
+
let msg = {};
|
|
38
|
+
const jsonArg = getArg("json");
|
|
39
|
+
if (jsonArg) {
|
|
40
|
+
const raw = jsonArg === "-"
|
|
41
|
+
? fs.readFileSync(0, "utf-8")
|
|
42
|
+
: fs.readFileSync(jsonArg, "utf-8");
|
|
43
|
+
msg = JSON.parse(raw);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const to = getArg("to");
|
|
47
|
+
if (!to) {
|
|
48
|
+
console.error("Usage: mailsend --to addr --subject text [--body text] [--from addr] [-q account]");
|
|
49
|
+
console.error(" mailsend --json message.json [-q account]");
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
msg = {
|
|
53
|
+
to: to.split(",").map(s => s.trim()),
|
|
54
|
+
subject: getArg("subject") || "(no subject)",
|
|
55
|
+
text: getArg("body") || "",
|
|
56
|
+
html: getArg("html"),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const acctId = msg.accountId || accountId;
|
|
60
|
+
const acct = config.accounts[acctId];
|
|
61
|
+
if (!acct) {
|
|
62
|
+
console.error(`Unknown account: ${acctId}`);
|
|
63
|
+
console.error(`Available: ${Object.keys(config.accounts).join(", ")}`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
msg.from = msg.from || getArg("from") || acct.from || acct.user;
|
|
67
|
+
msg.accountId = acctId;
|
|
68
|
+
if (!msg.to?.length) {
|
|
69
|
+
console.error("Message must have at least one recipient (to)");
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
const filename = queueMessage(msg);
|
|
73
|
+
console.log(`Queued: ${filename}`);
|
|
74
|
+
setTimeout(() => process.exit(0), 2000);
|
|
75
|
+
//# sourceMappingURL=cli-send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-send.js","sourceRoot":"","sources":["cli-send.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,YAAY,E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AI,EAAE,CAAC;IACR,OAAO,CAAC,KAAK,CAAC,oBAAoB,MAAM,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;AAChE,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC;AAEvB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAkB,CAAC,CAAC;AAClD,OAAO,CAAC,GAAG,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAC;AACnC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* mailsend — create and send an email message.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* mailsend --to addr --subject "text" --body "text"
|
|
7
|
+
* mailsend -q gmail --from "Bob <bob@gmail.com>" --to addr --subject "text"
|
|
8
|
+
* mailsend --json message.json Read message from JSON file
|
|
9
|
+
* echo '{"to":["a@b.com"],...}' | mailsend --json - Read from stdin
|
|
10
|
+
*
|
|
11
|
+
* JSON format:
|
|
12
|
+
* { "to": ["addr"], "cc": ["addr"], "from": "Name <addr>",
|
|
13
|
+
* "subject": "text", "text": "body", "html": "<p>body</p>",
|
|
14
|
+
* "accountId": "iecc" }
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as fs from "node:fs";
|
|
18
|
+
import { initMailSend, queueMessage, type MailSendConfig, type MailMessage } from "./index.js";
|
|
19
|
+
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
|
|
22
|
+
function getArg(name: string): string | undefined {
|
|
23
|
+
const shorts: Record<string, string> = { q: "queue" };
|
|
24
|
+
const longIdx = args.indexOf(`--${name}`);
|
|
25
|
+
const shortKey = Object.entries(shorts).find(([, v]) => v === name)?.[0];
|
|
26
|
+
const shortIdx = shortKey ? args.indexOf(`-${shortKey}`) : -1;
|
|
27
|
+
const i = Math.max(longIdx, shortIdx);
|
|
28
|
+
if (i === -1 || i + 1 >= args.length) return undefined;
|
|
29
|
+
return args[i + 1];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const configPath = getArg("config") || "mailsend.json";
|
|
33
|
+
if (!fs.existsSync(configPath)) {
|
|
34
|
+
console.error(`Config file not found: ${configPath}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const config: MailSendConfig = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
39
|
+
const sender = initMailSend(config);
|
|
40
|
+
const accountId = getArg("queue") || config.defaultAccount || "";
|
|
41
|
+
|
|
42
|
+
let msg: Partial<MailMessage> = {};
|
|
43
|
+
|
|
44
|
+
const jsonArg = getArg("json");
|
|
45
|
+
if (jsonArg) {
|
|
46
|
+
const raw = jsonArg === "-"
|
|
47
|
+
? fs.readFileSync(0, "utf-8")
|
|
48
|
+
: fs.readFileSync(jsonArg, "utf-8");
|
|
49
|
+
msg = JSON.parse(raw);
|
|
50
|
+
} else {
|
|
51
|
+
const to = getArg("to");
|
|
52
|
+
if (!to) {
|
|
53
|
+
console.error("Usage: mailsend --to addr --subject text [--body text] [--from addr] [-q account]");
|
|
54
|
+
console.error(" mailsend --json message.json [-q account]");
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
msg = {
|
|
58
|
+
to: to.split(",").map(s => s.trim()),
|
|
59
|
+
subject: getArg("subject") || "(no subject)",
|
|
60
|
+
text: getArg("body") || "",
|
|
61
|
+
html: getArg("html"),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const acctId = msg.accountId || accountId;
|
|
66
|
+
const acct = config.accounts[acctId];
|
|
67
|
+
if (!acct) {
|
|
68
|
+
console.error(`Unknown account: ${acctId}`);
|
|
69
|
+
console.error(`Available: ${Object.keys(config.accounts).join(", ")}`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
msg.from = msg.from || getArg("from") || acct.from || acct.user;
|
|
74
|
+
msg.accountId = acctId;
|
|
75
|
+
|
|
76
|
+
if (!msg.to?.length) {
|
|
77
|
+
console.error("Message must have at least one recipient (to)");
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const filename = queueMessage(msg as MailMessage);
|
|
82
|
+
console.log(`Queued: ${filename}`);
|
|
83
|
+
setTimeout(() => process.exit(0), 2000);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* mailx-send CLI — queue and send email.
|
|
4
|
+
*
|
|
5
|
+
* Queue management (process queued .ltr files):
|
|
6
|
+
* mailx-send --process Process all account queues now
|
|
7
|
+
* mailx-send --process -q gmail Process only the gmail queue
|
|
8
|
+
* mailx-send --status Show queue status
|
|
9
|
+
*
|
|
10
|
+
* Create and queue a new message:
|
|
11
|
+
* mailx-send --new --to addr --subject "text" --body "text"
|
|
12
|
+
* mailx-send --new -q gmail --from "Bob <bob@gmail.com>" --to addr --subject "text"
|
|
13
|
+
* mailx-send --new --json message.json Read message from JSON file
|
|
14
|
+
* echo '{"to":["a@b.com"],...}' | mailx-send --new --json - Read from stdin
|
|
15
|
+
*
|
|
16
|
+
* JSON message format:
|
|
17
|
+
* { "to": ["addr"], "cc": ["addr"], "from": "Name <addr>",
|
|
18
|
+
* "subject": "text", "text": "body", "html": "<p>body</p>",
|
|
19
|
+
* "accountId": "iecc" }
|
|
20
|
+
*/
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* mailx-send CLI — queue and send email.
|
|
4
|
+
*
|
|
5
|
+
* Queue management (process queued .ltr files):
|
|
6
|
+
* mailx-send --process Process all account queues now
|
|
7
|
+
* mailx-send --process -q gmail Process only the gmail queue
|
|
8
|
+
* mailx-send --status Show queue status
|
|
9
|
+
*
|
|
10
|
+
* Create and queue a new message:
|
|
11
|
+
* mailx-send --new --to addr --subject "text" --body "text"
|
|
12
|
+
* mailx-send --new -q gmail --from "Bob <bob@gmail.com>" --to addr --subject "text"
|
|
13
|
+
* mailx-send --new --json message.json Read message from JSON file
|
|
14
|
+
* echo '{"to":["a@b.com"],...}' | mailx-send --new --json - Read from stdin
|
|
15
|
+
*
|
|
16
|
+
* JSON message format:
|
|
17
|
+
* { "to": ["addr"], "cc": ["addr"], "from": "Name <addr>",
|
|
18
|
+
* "subject": "text", "text": "body", "html": "<p>body</p>",
|
|
19
|
+
* "accountId": "iecc" }
|
|
20
|
+
*/
|
|
21
|
+
import * as fs from "node:fs";
|
|
22
|
+
import { initMailSend, queueMessage } from "./index.js";
|
|
23
|
+
const args = process.argv.slice(2);
|
|
24
|
+
function getArg(name) {
|
|
25
|
+
const shorts = { q: "queue" };
|
|
26
|
+
const longIdx = args.indexOf(`--${name}`);
|
|
27
|
+
const shortKey = Object.entries(shorts).find(([, v]) => v === name)?.[0];
|
|
28
|
+
const shortIdx = shortKey ? args.indexOf(`-${shortKey}`) : -1;
|
|
29
|
+
const i = Math.max(longIdx, shortIdx);
|
|
30
|
+
if (i === -1 || i + 1 >= args.length)
|
|
31
|
+
return undefined;
|
|
32
|
+
return args[i + 1];
|
|
33
|
+
}
|
|
34
|
+
function hasFlag(name) {
|
|
35
|
+
return args.includes(`--${name}`);
|
|
36
|
+
}
|
|
37
|
+
// Load config
|
|
38
|
+
const configPath = getArg("config") || "mailsend.json";
|
|
39
|
+
if (!fs.existsSync(configPath)) {
|
|
40
|
+
console.error(`Config file not found: ${configPath}`);
|
|
41
|
+
console.error(`Create a mailsend.json with baseDir, accounts, etc.`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
45
|
+
const sender = initMailSend(config);
|
|
46
|
+
const accountId = getArg("queue") || config.defaultAccount || "";
|
|
47
|
+
// ── Queue management ──
|
|
48
|
+
if (hasFlag("status")) {
|
|
49
|
+
const status = sender.getStatus();
|
|
50
|
+
for (const [id, s] of Object.entries(status)) {
|
|
51
|
+
console.log(` ${id}: ${s.pending} pending, ${s.failed} failed`);
|
|
52
|
+
}
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
if (hasFlag("process") && !hasFlag("new")) {
|
|
56
|
+
if (accountId && accountId !== config.defaultAccount) {
|
|
57
|
+
await sender.processQueue(accountId);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
await sender.processAllQueues();
|
|
61
|
+
}
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
// ── Create new message ──
|
|
65
|
+
if (hasFlag("new")) {
|
|
66
|
+
let msg = {};
|
|
67
|
+
const jsonArg = getArg("json");
|
|
68
|
+
if (jsonArg) {
|
|
69
|
+
// Load from JSON file or stdin
|
|
70
|
+
const raw = jsonArg === "-"
|
|
71
|
+
? fs.readFileSync(0, "utf-8") // stdin
|
|
72
|
+
: fs.readFileSync(jsonArg, "utf-8");
|
|
73
|
+
msg = JSON.parse(raw);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Build from CLI args
|
|
77
|
+
const to = getArg("to");
|
|
78
|
+
if (!to) {
|
|
79
|
+
console.error("--new requires --to or --json");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
msg = {
|
|
83
|
+
to: to.split(",").map(s => s.trim()),
|
|
84
|
+
subject: getArg("subject") || "(no subject)",
|
|
85
|
+
text: getArg("body") || "",
|
|
86
|
+
html: getArg("html"),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// Set from/account
|
|
90
|
+
const acctId = msg.accountId || accountId;
|
|
91
|
+
const acct = config.accounts[acctId];
|
|
92
|
+
if (!acct) {
|
|
93
|
+
console.error(`Unknown account: ${acctId}`);
|
|
94
|
+
console.error(`Available: ${Object.keys(config.accounts).join(", ")}`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
msg.from = msg.from || getArg("from") || acct.from || acct.user;
|
|
98
|
+
msg.accountId = acctId;
|
|
99
|
+
if (!msg.to?.length) {
|
|
100
|
+
console.error("Message must have at least one recipient (to)");
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
const filename = queueMessage(msg);
|
|
104
|
+
console.log(`Queued: ${filename}`);
|
|
105
|
+
setTimeout(() => process.exit(0), 2000);
|
|
106
|
+
}
|
|
107
|
+
else if (!hasFlag("status") && !hasFlag("process")) {
|
|
108
|
+
console.error("Usage:");
|
|
109
|
+
console.error(" mailx-send --new --to addr --subject text [--body text] [-q account]");
|
|
110
|
+
console.error(" mailx-send --new --json message.json [-q account]");
|
|
111
|
+
console.error(" mailx-send --process [-q account]");
|
|
112
|
+
console.error(" mailx-send --status");
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=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,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* mailx-send CLI — queue and send email.
|
|
4
|
+
*
|
|
5
|
+
* Queue management (process queued .ltr files):
|
|
6
|
+
* mailx-send --process Process all account queues now
|
|
7
|
+
* mailx-send --process -q gmail Process only the gmail queue
|
|
8
|
+
* mailx-send --status Show queue status
|
|
9
|
+
*
|
|
10
|
+
* Create and queue a new message:
|
|
11
|
+
* mailx-send --new --to addr --subject "text" --body "text"
|
|
12
|
+
* mailx-send --new -q gmail --from "Bob <bob@gmail.com>" --to addr --subject "text"
|
|
13
|
+
* mailx-send --new --json message.json Read message from JSON file
|
|
14
|
+
* echo '{"to":["a@b.com"],...}' | mailx-send --new --json - Read from stdin
|
|
15
|
+
*
|
|
16
|
+
* JSON message format:
|
|
17
|
+
* { "to": ["addr"], "cc": ["addr"], "from": "Name <addr>",
|
|
18
|
+
* "subject": "text", "text": "body", "html": "<p>body</p>",
|
|
19
|
+
* "accountId": "iecc" }
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import * as fs from "node:fs";
|
|
23
|
+
import { initMailSend, queueMessage, type MailSendConfig, type MailMessage } from "./index.js";
|
|
24
|
+
|
|
25
|
+
const args = process.argv.slice(2);
|
|
26
|
+
|
|
27
|
+
function getArg(name: string): string | undefined {
|
|
28
|
+
const shorts: Record<string, string> = { q: "queue" };
|
|
29
|
+
const longIdx = args.indexOf(`--${name}`);
|
|
30
|
+
const shortKey = Object.entries(shorts).find(([, v]) => v === name)?.[0];
|
|
31
|
+
const shortIdx = shortKey ? args.indexOf(`-${shortKey}`) : -1;
|
|
32
|
+
const i = Math.max(longIdx, shortIdx);
|
|
33
|
+
if (i === -1 || i + 1 >= args.length) return undefined;
|
|
34
|
+
return args[i + 1];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function hasFlag(name: string): boolean {
|
|
38
|
+
return args.includes(`--${name}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Load config
|
|
42
|
+
const configPath = getArg("config") || "mailsend.json";
|
|
43
|
+
if (!fs.existsSync(configPath)) {
|
|
44
|
+
console.error(`Config file not found: ${configPath}`);
|
|
45
|
+
console.error(`Create a mailsend.json with baseDir, accounts, etc.`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const config: MailSendConfig = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
50
|
+
const sender = initMailSend(config);
|
|
51
|
+
const accountId = getArg("queue") || config.defaultAccount || "";
|
|
52
|
+
|
|
53
|
+
// ── Queue management ──
|
|
54
|
+
|
|
55
|
+
if (hasFlag("status")) {
|
|
56
|
+
const status = sender.getStatus();
|
|
57
|
+
for (const [id, s] of Object.entries(status)) {
|
|
58
|
+
console.log(` ${id}: ${s.pending} pending, ${s.failed} failed`);
|
|
59
|
+
}
|
|
60
|
+
process.exit(0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (hasFlag("process") && !hasFlag("new")) {
|
|
64
|
+
if (accountId && accountId !== config.defaultAccount) {
|
|
65
|
+
await sender.processQueue(accountId);
|
|
66
|
+
} else {
|
|
67
|
+
await sender.processAllQueues();
|
|
68
|
+
}
|
|
69
|
+
process.exit(0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── Create new message ──
|
|
73
|
+
|
|
74
|
+
if (hasFlag("new")) {
|
|
75
|
+
let msg: Partial<MailMessage> = {};
|
|
76
|
+
|
|
77
|
+
const jsonArg = getArg("json");
|
|
78
|
+
if (jsonArg) {
|
|
79
|
+
// Load from JSON file or stdin
|
|
80
|
+
const raw = jsonArg === "-"
|
|
81
|
+
? fs.readFileSync(0, "utf-8") // stdin
|
|
82
|
+
: fs.readFileSync(jsonArg, "utf-8");
|
|
83
|
+
msg = JSON.parse(raw);
|
|
84
|
+
} else {
|
|
85
|
+
// Build from CLI args
|
|
86
|
+
const to = getArg("to");
|
|
87
|
+
if (!to) {
|
|
88
|
+
console.error("--new requires --to or --json");
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
msg = {
|
|
92
|
+
to: to.split(",").map(s => s.trim()),
|
|
93
|
+
subject: getArg("subject") || "(no subject)",
|
|
94
|
+
text: getArg("body") || "",
|
|
95
|
+
html: getArg("html"),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Set from/account
|
|
100
|
+
const acctId = msg.accountId || accountId;
|
|
101
|
+
const acct = config.accounts[acctId];
|
|
102
|
+
if (!acct) {
|
|
103
|
+
console.error(`Unknown account: ${acctId}`);
|
|
104
|
+
console.error(`Available: ${Object.keys(config.accounts).join(", ")}`);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
msg.from = msg.from || getArg("from") || acct.from || acct.user;
|
|
109
|
+
msg.accountId = acctId;
|
|
110
|
+
|
|
111
|
+
if (!msg.to?.length) {
|
|
112
|
+
console.error("Message must have at least one recipient (to)");
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const filename = queueMessage(msg as MailMessage);
|
|
117
|
+
console.log(`Queued: ${filename}`);
|
|
118
|
+
setTimeout(() => process.exit(0), 2000);
|
|
119
|
+
} else if (!hasFlag("status") && !hasFlag("process")) {
|
|
120
|
+
console.error("Usage:");
|
|
121
|
+
console.error(" mailx-send --new --to addr --subject text [--body text] [-q account]");
|
|
122
|
+
console.error(" mailx-send --new --json message.json [-q account]");
|
|
123
|
+
console.error(" mailx-send --process [-q account]");
|
|
124
|
+
console.error(" mailx-send --status");
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
export interface SmtpConfig {
|
|
13
|
+
host: string;
|
|
14
|
+
port: number;
|
|
15
|
+
secure?: boolean;
|
|
16
|
+
auth: "password" | "oauth2";
|
|
17
|
+
user: string;
|
|
18
|
+
password?: string;
|
|
19
|
+
/** Default From address, e.g. "Bob Frankston <bob@iecc.com>" */
|
|
20
|
+
from?: string;
|
|
21
|
+
tokenProvider?: () => Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
export interface MailMessage {
|
|
24
|
+
from: string;
|
|
25
|
+
to: string[];
|
|
26
|
+
cc?: string[];
|
|
27
|
+
bcc?: string[];
|
|
28
|
+
subject: string;
|
|
29
|
+
html?: string;
|
|
30
|
+
text?: string;
|
|
31
|
+
inReplyTo?: string;
|
|
32
|
+
references?: string;
|
|
33
|
+
accountId?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface MailSendConfig {
|
|
36
|
+
/** Base directory for all queues */
|
|
37
|
+
baseDir: string;
|
|
38
|
+
/** SMTP configs keyed by account ID */
|
|
39
|
+
accounts: Record<string, SmtpConfig>;
|
|
40
|
+
/** Log sent messages to sent/ subdirectory */
|
|
41
|
+
logSent?: boolean;
|
|
42
|
+
/** Retry interval in ms (default: 5 minutes) */
|
|
43
|
+
retryIntervalMs?: number;
|
|
44
|
+
/** Default account ID */
|
|
45
|
+
defaultAccount?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function buildRfc822(msg: MailMessage): string;
|
|
48
|
+
export declare class MailSender {
|
|
49
|
+
private config;
|
|
50
|
+
private processing;
|
|
51
|
+
private retryTimer;
|
|
52
|
+
constructor(config: MailSendConfig);
|
|
53
|
+
private accountDir;
|
|
54
|
+
private queueDir;
|
|
55
|
+
private sentDir;
|
|
56
|
+
private failDir;
|
|
57
|
+
/** Queue a message. Returns the filename. */
|
|
58
|
+
queueMessage(msg: MailMessage): string;
|
|
59
|
+
/** Process pending messages for one account */
|
|
60
|
+
processQueue(accountId: string): Promise<void>;
|
|
61
|
+
/** Process all account queues */
|
|
62
|
+
processAllQueues(): Promise<void>;
|
|
63
|
+
private sendFile;
|
|
64
|
+
/** Start background worker — retries failed, processes queues */
|
|
65
|
+
startWorker(): void;
|
|
66
|
+
private retryFailed;
|
|
67
|
+
stopWorker(): void;
|
|
68
|
+
/** Get queue status per account */
|
|
69
|
+
getStatus(): Record<string, {
|
|
70
|
+
pending: number;
|
|
71
|
+
failed: number;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
export declare function initMailSend(config: MailSendConfig): MailSender;
|
|
75
|
+
export declare function getMailSender(): MailSender | null;
|
|
76
|
+
export declare function queueMessage(msg: MailMessage): string;
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,GAAG,CAAC,EAAE,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