Structured Errors & Delivery States

MailPort provides explicit error classes with retryable flags, delivery certainty classifications, and automatic credential redaction.

Delivery States

Error Hierarchy

import {
  MailError,
  MailAuthError,
  MailConnectionError,
  MailUncertainError,
} from 'mailport';

try {
  await mailer.send(message);
} catch (err) {
  if (err instanceof MailAuthError) {
    console.error('SMTP credentials rejected');
  } else if (err instanceof MailConnectionError) {
    console.error('Connection failed prior to send. Retryable:', err.retryable);
  } else if (err instanceof MailUncertainError) {
    console.error('Network lost after body payload. Delivery status uncertain.');
  }
}