Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6cdc619cd0 | |||
| c3d4c4abb5 | |||
| 08c5145d20 | |||
| 0515d2ae46 | |||
| 96b4ccb7d3 | |||
| 7c0c327913 | |||
| 9e722874b4 | |||
| 873af43ef2 | |||
| 76d898b648 | |||
| b422639c34 |
34
changelog.md
34
changelog.md
@@ -1,5 +1,39 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-02-11 - 5.2.1 - fix(rust-bridge)
|
||||||
|
map Node.js platform/arch to tsrust-style suffix and add platform-specific and dev localPaths for RustBridge
|
||||||
|
|
||||||
|
- Add getPlatformSuffix() to map process.platform/process.arch to tsrust-style suffixes (e.g. linux_amd64)
|
||||||
|
- Include dist_rust/mailer-bin_{suffix} when available to prefer cross-compiled binaries
|
||||||
|
- Consolidate localPaths and add local dev build paths (rust/target/release and rust/target/debug)
|
||||||
|
- Pass the computed localPaths array into plugins.smartrust.RustBridge (searchSystemPath remains disabled)
|
||||||
|
|
||||||
|
## 2026-02-11 - 5.2.0 - feat(packaging)
|
||||||
|
add package exports entry, include ts/dist_ts in package files, and add TS barrel index re-exports
|
||||||
|
|
||||||
|
- package.json: add "exports" mapping "." -> "./dist_ts/index.js" to provide a module entry point
|
||||||
|
- package.json: add "ts/**/*" and "dist_ts/**/*" to "files" so TypeScript sources and built output are published
|
||||||
|
- ts/index.ts: new barrel that re-exports './00_commitinfo_data.js', './mail/index.js', and './security/index.js'
|
||||||
|
|
||||||
|
## 2026-02-11 - 5.1.3 - fix(docs)
|
||||||
|
clarify sendEmail default behavior and document automatic MX discovery and delivery modes
|
||||||
|
|
||||||
|
- Updated README to describe automatic MX record discovery and grouping behavior when using sendEmail() (MTA mode)
|
||||||
|
- Added a Delivery Modes section and API signature for sendEmail(mode) describing mta, forward, and process options
|
||||||
|
- Expanded examples to show multi-recipient delivery, explicit mode usage, and retained low-level sendOutboundEmail example
|
||||||
|
|
||||||
|
## 2026-02-11 - 5.1.2 - fix(readme)
|
||||||
|
adjust ASCII architecture diagram alignment in README
|
||||||
|
|
||||||
|
- Whitespace and alignment tweaks to the ASCII architecture diagram in readme.md
|
||||||
|
- No code or behavior changes; documentation-only edit
|
||||||
|
|
||||||
|
## 2026-02-11 - 5.1.1 - fix(release)
|
||||||
|
no changes
|
||||||
|
|
||||||
|
- No files changed in this commit.
|
||||||
|
- Current package version remains 5.1.0 (from package.json).
|
||||||
|
|
||||||
## 2026-02-11 - 5.1.0 - feat(mailer-smtp)
|
## 2026-02-11 - 5.1.0 - feat(mailer-smtp)
|
||||||
add SCRAM-SHA-256 auth, Ed25519 DKIM, opportunistic TLS, SNI cert selection, pipelining and delivery/bridge improvements
|
add SCRAM-SHA-256 auth, Ed25519 DKIM, opportunistic TLS, SNI cert selection, pipelining and delivery/bridge improvements
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartmta",
|
"name": "@push.rocks/smartmta",
|
||||||
"version": "5.1.0",
|
"version": "5.2.1",
|
||||||
"description": "A high-performance, enterprise-grade Mail Transfer Agent (MTA) built from scratch in TypeScript with Rust acceleration.",
|
"description": "A high-performance, enterprise-grade Mail Transfer Agent (MTA) built from scratch in TypeScript with Rust acceleration.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"mta",
|
"mta",
|
||||||
@@ -27,6 +27,9 @@
|
|||||||
"author": "Task Venture Capital GmbH",
|
"author": "Task Venture Capital GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist_ts/index.js"
|
||||||
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"mailer": "./bin/mailer-wrapper.js"
|
"mailer": "./bin/mailer-wrapper.js"
|
||||||
},
|
},
|
||||||
@@ -56,6 +59,8 @@
|
|||||||
"uuid": "^13.0.0"
|
"uuid": "^13.0.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
"bin/",
|
"bin/",
|
||||||
"scripts/install-binary.js",
|
"scripts/install-binary.js",
|
||||||
"dist_rust/**/*",
|
"dist_rust/**/*",
|
||||||
|
|||||||
61
readme.md
61
readme.md
@@ -1,6 +1,6 @@
|
|||||||
# @push.rocks/smartmta
|
# @push.rocks/smartmta
|
||||||
|
|
||||||
A high-performance, enterprise-grade Mail Transfer Agent (MTA) built from scratch in TypeScript with a Rust-powered SMTP engine — no nodemailer, no shortcuts. 🚀
|
A high-performance, enterprise-grade Mail Transfer Agent (MTA) built from scratch in TypeScript with a Rust-powered SMTP engine — no nodemailer, no shortcuts. Automatic MX record discovery means you just call `sendEmail()` and smartmta figures out where to deliver. 🚀
|
||||||
|
|
||||||
## Issue Reporting and Security
|
## Issue Reporting and Security
|
||||||
|
|
||||||
@@ -78,9 +78,10 @@ After installation, run `pnpm build` to compile the Rust binary (`mailer-bin`).
|
|||||||
|
|
||||||
**Data flow for outbound mail:**
|
**Data flow for outbound mail:**
|
||||||
|
|
||||||
1. 📝 TypeScript constructs the email and resolves DKIM keys for the sender domain
|
1. 📝 TypeScript constructs the email and calls `sendEmail()` (defaults to MTA mode)
|
||||||
2. 🦀 Sends to Rust via IPC — Rust builds the RFC 2822 message, signs with DKIM, and delivers via its SMTP client with connection pooling
|
2. 🔍 MTA mode automatically resolves MX records for each recipient domain, sorts by priority, and groups recipients for efficient delivery
|
||||||
3. 📬 Result (accepted/rejected recipients, server response) returned to TypeScript
|
3. 🦀 Sends to Rust via IPC — Rust builds the RFC 2822 message, signs with DKIM, and delivers via its SMTP client with connection pooling
|
||||||
|
4. 📬 Result (accepted/rejected recipients, server response) returned to TypeScript
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -169,9 +170,9 @@ await emailServer.start();
|
|||||||
|
|
||||||
> 🔒 **Note:** `start()` will throw if the Rust binary is not compiled. Run `pnpm build` first.
|
> 🔒 **Note:** `start()` will throw if the Rust binary is not compiled. Run `pnpm build` first.
|
||||||
|
|
||||||
### 📧 Sending Outbound Emails
|
### 📧 Sending Emails (Automatic MX Discovery)
|
||||||
|
|
||||||
All outbound email delivery goes through the Rust SMTP client, accessed via `UnifiedEmailServer.sendOutboundEmail()`. The Rust client handles connection pooling, TLS negotiation, and DKIM signing automatically:
|
The recommended way to send email is `sendEmail()`. It defaults to **MTA mode**, which automatically resolves MX records for each recipient domain via DNS — you don't need to know the destination mail server:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { Email, UnifiedEmailServer } from '@push.rocks/smartmta';
|
import { Email, UnifiedEmailServer } from '@push.rocks/smartmta';
|
||||||
@@ -179,8 +180,7 @@ import { Email, UnifiedEmailServer } from '@push.rocks/smartmta';
|
|||||||
// Build an email
|
// Build an email
|
||||||
const email = new Email({
|
const email = new Email({
|
||||||
from: 'sender@example.com',
|
from: 'sender@example.com',
|
||||||
to: ['recipient@example.com'],
|
to: ['alice@gmail.com', 'bob@company.org'],
|
||||||
cc: ['cc@example.com'],
|
|
||||||
subject: 'Hello from smartmta! 🚀',
|
subject: 'Hello from smartmta! 🚀',
|
||||||
text: 'Plain text body',
|
text: 'Plain text body',
|
||||||
html: '<h1>Hello!</h1><p>HTML body with <strong>formatting</strong></p>',
|
html: '<h1>Hello!</h1><p>HTML body with <strong>formatting</strong></p>',
|
||||||
@@ -194,7 +194,50 @@ const email = new Email({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send via the Rust SMTP client (connection pooling, TLS, DKIM signing)
|
// Send — MTA mode auto-discovers MX servers for gmail.com and company.org
|
||||||
|
const emailId = await emailServer.sendEmail(email);
|
||||||
|
|
||||||
|
// Optionally specify a delivery mode explicitly
|
||||||
|
const emailId2 = await emailServer.sendEmail(email, 'mta');
|
||||||
|
```
|
||||||
|
|
||||||
|
In MTA mode, smartmta:
|
||||||
|
- 🔍 Resolves MX records for each recipient domain (e.g. `gmail.com`, `company.org`)
|
||||||
|
- 📊 Sorts MX hosts by priority (lowest = highest priority per RFC 5321)
|
||||||
|
- 🔄 Tries each MX host in order until delivery succeeds
|
||||||
|
- 🌐 Falls back to the domain's A record if no MX records exist
|
||||||
|
- 📦 Groups recipients by domain for efficient batch delivery
|
||||||
|
- 🔑 Signs outbound mail with DKIM automatically
|
||||||
|
|
||||||
|
### 📮 Delivery Modes
|
||||||
|
|
||||||
|
`sendEmail()` accepts a mode parameter that controls how the email is delivered:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
public async sendEmail(
|
||||||
|
email: Email,
|
||||||
|
mode: EmailProcessingMode = 'mta', // 'mta' | 'forward' | 'process'
|
||||||
|
route?: IEmailRoute,
|
||||||
|
options?: {
|
||||||
|
skipSuppressionCheck?: boolean;
|
||||||
|
ipAddress?: string;
|
||||||
|
isTransactional?: boolean;
|
||||||
|
}
|
||||||
|
): Promise<string>
|
||||||
|
```
|
||||||
|
|
||||||
|
| Mode | Description |
|
||||||
|
|---|---|
|
||||||
|
| `mta` (default) | **Auto MX discovery** — resolves MX records via DNS, delivers directly to the recipient's mail server. No relay configuration needed. |
|
||||||
|
| `forward` | **Relay delivery** — forwards the email to a configured SMTP host (e.g. an internal mail gateway or third-party relay). |
|
||||||
|
| `process` | **Scan + deliver** — runs the content scanning / security pipeline first, then delivers via auto MX resolution. |
|
||||||
|
|
||||||
|
### 📬 Direct SMTP Delivery (Low-Level)
|
||||||
|
|
||||||
|
For cases where you know the exact target SMTP server (e.g. relaying to a specific host), use the lower-level `sendOutboundEmail()`:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Send directly to a known SMTP server (bypasses MX resolution)
|
||||||
const result = await emailServer.sendOutboundEmail('smtp.example.com', 587, email, {
|
const result = await emailServer.sendOutboundEmail('smtp.example.com', 587, email, {
|
||||||
auth: { user: 'sender@example.com', pass: 'your-password' },
|
auth: { user: 'sender@example.com', pass: 'your-password' },
|
||||||
dkimDomain: 'example.com',
|
dkimDomain: 'example.com',
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartmta',
|
name: '@push.rocks/smartmta',
|
||||||
version: '5.1.0',
|
version: '5.2.1',
|
||||||
description: 'A high-performance, enterprise-grade Mail Transfer Agent (MTA) built from scratch in TypeScript with Rust acceleration.'
|
description: 'A high-performance, enterprise-grade Mail Transfer Agent (MTA) built from scratch in TypeScript with Rust acceleration.'
|
||||||
}
|
}
|
||||||
|
|||||||
3
ts/index.ts
Normal file
3
ts/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export * from './00_commitinfo_data.js';
|
||||||
|
export * from './mail/index.js';
|
||||||
|
export * from './security/index.js';
|
||||||
@@ -375,18 +375,39 @@ export class RustSecurityBridge extends EventEmitter {
|
|||||||
private _deliberateStop = false;
|
private _deliberateStop = false;
|
||||||
private _smtpServerConfig: ISmtpServerConfig | null = null;
|
private _smtpServerConfig: ISmtpServerConfig | null = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map Node.js process.platform / process.arch to the tsrust-style suffix
|
||||||
|
* used for cross-compiled binaries, e.g. mailer-bin_linux_amd64.
|
||||||
|
*/
|
||||||
|
private static getPlatformSuffix(): string | null {
|
||||||
|
const archMap: Record<string, string> = { x64: 'amd64', arm64: 'arm64' };
|
||||||
|
const os = process.platform; // 'linux', 'darwin', 'win32', …
|
||||||
|
const arch = archMap[process.arch];
|
||||||
|
if (!arch) return null;
|
||||||
|
return `${os}_${arch}`;
|
||||||
|
}
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
const suffix = RustSecurityBridge.getPlatformSuffix();
|
||||||
|
const localPaths: string[] = [];
|
||||||
|
|
||||||
|
// dist_rust/ candidates (tsrust cross-compiled output)
|
||||||
|
if (suffix) {
|
||||||
|
localPaths.push(plugins.path.join(paths.packageDir, 'dist_rust', `mailer-bin_${suffix}`));
|
||||||
|
}
|
||||||
|
localPaths.push(plugins.path.join(paths.packageDir, 'dist_rust', 'mailer-bin'));
|
||||||
|
// Local dev build paths
|
||||||
|
localPaths.push(plugins.path.join(paths.packageDir, 'rust', 'target', 'release', 'mailer-bin'));
|
||||||
|
localPaths.push(plugins.path.join(paths.packageDir, 'rust', 'target', 'debug', 'mailer-bin'));
|
||||||
|
|
||||||
this.bridge = new plugins.smartrust.RustBridge<TMailerCommands>({
|
this.bridge = new plugins.smartrust.RustBridge<TMailerCommands>({
|
||||||
binaryName: 'mailer-bin',
|
binaryName: 'mailer-bin',
|
||||||
cliArgs: ['--management'],
|
cliArgs: ['--management'],
|
||||||
requestTimeoutMs: 30_000,
|
requestTimeoutMs: 30_000,
|
||||||
readyTimeoutMs: 10_000,
|
readyTimeoutMs: 10_000,
|
||||||
localPaths: [
|
localPaths,
|
||||||
plugins.path.join(paths.packageDir, 'dist_rust', 'mailer-bin'),
|
|
||||||
plugins.path.join(paths.packageDir, 'rust', 'target', 'release', 'mailer-bin'),
|
|
||||||
plugins.path.join(paths.packageDir, 'rust', 'target', 'debug', 'mailer-bin'),
|
|
||||||
],
|
|
||||||
searchSystemPath: false,
|
searchSystemPath: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user