Skip to content
Pilotoo
v0.1

@pilotoo/connections-mail

@pilotoo/connections-mail implements the MailTransport port that the Email (IMAP/SMTP) provider of @pilotoo/connections-core needs. SMTP goes through nodemailer and IMAP through imapflow. Before it opens a connection it refuses a host that resolves to a private, loopback or link-local address and any port outside the mail ports.

@pilotoo/connections-mail is at version 0.1.0, is marked private and is not published to a registry. It is also not part of the tarballs that pnpm release:check packs, so today it is used from the kit workspace:

Terminal window
pnpm install
pnpm --filter @pilotoo/connections-mail build

Inside the workspace, depend on it with "@pilotoo/connections-mail": "workspace:^". Its build first builds the kit packages it depends on.

Create the transport and pass it next to the providers:

src/app.module.ts
import { mailProvider } from '@pilotoo/connections-core';
import { createMailTransport } from '@pilotoo/connections-mail';
PilotooModule.forRoot({
connections: {
providers: [mailProvider()],
mail: createMailTransport(),
tools: true,
},
});
Option Default Meaning
allowPrivateHosts false Allow loopback, private and link-local hosts. The mail ports stay enforced.
timeoutMs 20000 Deadline of each operation.

resolve, imapClient and smtpTransport replace DNS resolution and the two library clients; they exist for tests.

The provider, its tools and its credential fields are described in Providers.

Import Provides
@pilotoo/connections-mail createMailTransport and the types MailTransportOptions, ImapOptions, ImapClientFactory, ImapClientLike, SmtpOptions, SmtpTransportFactory, SmtpTransporter and Resolve.

@pilotoo/connections-core, nodemailer, imapflow and mailparser. It has no peer dependencies.