Skip to content

@saflib/email


@saflib/email

Classes

ClassDescription
EmailClientA simplified client for sending emails, wrapping around nodemailer (or a mock in during tests).

Interfaces

InterfaceDescription
EmailOptionsAccepted options when sending an email. A subset of what nodemailer accepts. See Nodemailer docs for more details.
EmailResultResult of sending an email. This seems to be what is returned by nodemailer when the transport is SMTP. These types may not be correct if configured to use some other transport.
EmailsRouterOptions-
SentEmailA record of an email that was sent. Only used for mocking.

Variables

VariableDescription
emailClientGlobal instance of the email client. Since the config is loaded by the environment, and services shouldn't try to set up multiple SMTP connections, this can be a singleton.
mockingOnWhether the email client is currently being mocked, and emails are being saved to sentEmails.
sentEmailsAn array of emails that were sent by this service. Only used for mocking.

Functions

FunctionDescription
createEmailsRouterCreates an Express router that can be used to access sent emails. Only used for E2E testing.