Bounded-Memory Attachment Streaming
Stream 10 MB, 100 MB, or larger attachments with bounded memory usage.
Supported Attachment Types
- BufferAttachment: In-memory Uint8Array or Buffer.
- PathAttachment: Local filesystem path streamed chunk-by-chunk.
-
StreamAttachment: Any
AsyncIterable<Uint8Array>stream source.
import { createReadStream } from 'node:fs';
import { createMailer, smtp } from 'mailport';
const mailer = createMailer({ transport: smtp({ host: process.env.SMTP_HOST! }) });
await mailer.send({
from: 'reports@example.com',
to: 'analytics@example.com',
subject: 'Monthly Export',
attachments: [
{
type: 'stream',
filename: 'export_100mb.csv',
stream: createReadStream('./export_100mb.csv'),
},
],
});