Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 915 Bytes

client.md

File metadata and controls

54 lines (40 loc) · 915 Bytes

SMTP Client

Usage

SMTPClient

Events:

import { SMTPClient } from '@typemail/smtp/client';

const message = {
  sender: 'a@example.com',
  recipients: ['b@example.com'],
  message: 'MESSAGE',
};

const client = new SMTPClient({ hostname: HOST, port: PORT });
client.on('ready', () => {
  client.mail(message);
  client.close();
});

Async/await:

import { SMTPClient } from '@typemail/smtp/client';

const message = {
  sender: 'a@example.com',
  recipients: ['b@example.com'],
  message: 'MESSAGE',
};

const client = new SMTPClient({ hostname: HOST, port: PORT });
await client.connect();
await client.mail(message);
client.close();

sendmail

import { sendmail } from '@typemail/smtp/client';

const message = {
  sender: 'a@example.com',
  recipients: ['b@example.com'],
  message: 'MESSAGE',
};

sendmail(message, { smtp: { hostname: HOST, port: PORT } });