@taiatiniyara/smtp-relay-client
v2.0.0
Published
Client library for @taiatiniyara/smtp-relay
Readme
@taiatiniyara/smtp-relay-client
Client library for @taiatiniyara/smtp-relay — a minimal SMTP relay server.
Install
npm i @taiatiniyara/smtp-relay-clientRequires Node.js 18+ (uses native fetch).
Usage
import { SmtpRelayClient } from '@taiatiniyara/smtp-relay-client';
const relay = new SmtpRelayClient({
url: 'https://relay.example.com',
pin: '0000',
timeout: 30_000, // optional, defaults to 30s
});
await relay.send(
{
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: { user: '[email protected]', pass: 'app-password' },
},
{
from: '[email protected]',
to: '[email protected]',
subject: 'Hello',
html: '<h1>Hello World</h1>',
},
);API
new SmtpRelayClient(options)
| Option | Type | Default | Description |
| --------- | -------- | -------- | ------------------------ |
| url | string | required | Relay server URL |
| pin | string | required | Shared secret PIN |
| timeout | number | 30000 | Request timeout in ms |
client.send(config, email)
Returns Promise<{ message: string }> on success.
Throws RelayError on failure:
| error.status | Cause |
| -------------- | ---------------------------- |
| 401 | Invalid PIN |
| 408 | Request timed out |
| 500 | Server failed to send email |
| 0 | Network / fetch error |
Types
import type { EmailConfig, Email, SendResult, ClientOptions } from '@taiatiniyara/smtp-relay-client';
import { RelayError } from '@taiatiniyara/smtp-relay-client';