Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Effect KitEmails

Layers and environment variables

The three layer constructors every provider exports, and the environment variables each default layerConfig reads.

Every provider subpath exports layer, layerClient and layerConfig. Each returns a Layer that provides Email.

ConstructorTakesClient
layer(options)Resolved options, with secrets as Redacted.Creates the SDK client and owns it. The client is closed with the layer's scope, where the SDK has something to close.
layerClient(client, options?)A client you built.Borrowed. The package never closes it, and the client keeps its own retry, timeout and logging policy.
layerConfig(config?)An Effect Config of the options.As layer.

layerConfig has a default Config that reads the environment variables below. Mailtrap has no default, so its config argument is required.

Example (Reading Environment Variables With the Default Config)

import { , ,  } from "effect";
import {  } from "@effect-kit/emails";
import * as  from "@effect-kit/emails/resend";

const  = .().(
  .(.(.())),
);

const  = .(function* () {
  const  = yield* ;
  return .;
}).(.());

Layer errors are typed: layerConfig can fail with Config.ConfigError for a missing or malformed variable, and every constructor can fail with the provider's configuration error. See Errors.

Redacted secrets must be printable ASCII with no whitespace. Every provider accepts a timeout option of a finite, positive Duration. The default is 30 seconds, and 60 seconds for azure.

Environment variables

These are the variables the default layerConfig reads.

ProviderVariables
resendRESEND_API_KEY
nodemailerSMTP_HOST, SMTP_PORT (default 587), SMTP_SECURE (default false), SMTP_USER, SMTP_PASSWORD
sesAWS_REGION
azureAZURE_EMAIL_CONNECTION_STRING
postmarkPOSTMARK_SERVER_TOKEN
sendgridSENDGRID_API_KEY
mailgunMAILGUN_API_KEY, MAILGUN_DOMAIN, MAILGUN_REGION (us or eu)
mailersendMAILERSEND_API_KEY
brevoBREVO_API_KEY
mailtrapnone, pass a Config
scalewaySCW_ACCESS_KEY, SCW_SECRET_KEY, SCW_PROJECT_ID, SCW_REGION (fr-par)
lettermintLETTERMINT_SENDING_TOKEN
eusendEUSEND_API_KEY
zeptomailZEPTOMAIL_TOKEN, ZEPTOMAIL_URL
mailchimp-transactionalMAILCHIMP_TRANSACTIONAL_API_KEY
plunkPLUNK_API_KEY

The default nodemailer config requires SMTP_USER and SMTP_PASSWORD. For an SMTP server without authentication, use Nodemailer.layer with a transport that has no auth.

Options the default config does not read, such as baseUrl, messageStream, sandbox or SES credentials, need a custom Config or layer.

Options by provider

timeout is accepted everywhere and is omitted below.

Providerlayer options
resendapiKey, baseUrl?
nodemailertransport (host, port?, secure?, requireTLS?, auth?, pool?, maxConnections?, maxMessages?, connectionTimeout?, greetingTimeout?, socketTimeout?)
sesregion, credentials?, endpoint?, configurationSetName?
azureconnectionString, pollInterval?
postmarkserverToken, messageStream?
sendgridapiKey
mailgunapiKey, domain, region, endpoint?
mailersendapiKey
brevoapiKey
mailtraptoken, mode, inboxId (a number, required for sandbox, not allowed otherwise)
scalewayaccessKey, secretKey, projectId, region
lettermintsendingToken, sandbox?
eusendapiKey, baseUrl?
zeptomailtoken, url
mailchimp-transactionalapiKey, baseUrl?
plunkapiKey, baseUrl?

layerClient options

The second argument is optional for every provider except these three, where it holds required fields.

ProviderRequired options
mailgundomain
mailtrapmode
scalewayprojectId, region