SMTP Transport Architecture & Options
Single-Connection Model
MailPort currently uses a single-connection transport model: for every email message send operation, MailPort establishes a new TCP connection, negotiates TLS via STARTTLS, performs SASL authentication, streams the MIME payload, and issues QUIT to close the socket.
Why Single Connection Was Chosen
- Reliability & Determinism: Avoids silent socket timeouts, broken pipe errors, or unhandled socket resets common in persistent connection pools.
- Strict Phase Isolation: Each attempt starts with a clean socket state, ensuring authentication and envelope state cannot leak across calls.
- Expected Throughput: ~50 to 100 messages/sec per connection depending on network round-trip time and TLS handshake overhead.
- Connection Pooling: Connection pooling is planned for future 1.x releases for high-throughput bulk sending workloads.
Configuration Options
import { smtp } from 'mailport';
const transport = smtp({
host: 'smtp.example.com',
port: 587,
tls: 'starttls', // 'starttls' | 'implicit' | 'none'
auth: {
user: process.env.SMTP_USER!,
pass: process.env.SMTP_PASSWORD!,
},
timeouts: {
connectionMs: 10000,
greetingMs: 10000,
commandMs: 10000,
},
});