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

Mailchimp Transactional

Send email through Mailchimp Transactional with the @effect-kit/emails/mailchimp-transactional Layer.

The @effect-kit/emails/mailchimp-transactional subpath sends messages through Mailchimp Transactional and provides the Email service.

Installation

npm install @effect-kit/emails effect @mailchimp/mailchimp_transactional@1.4.1

The SDK is a pinned optional peer. It is needed only when you import this subpath.

Setup

MailchimpTransactional.layerConfig() reads these variables:

VariableRequiredValue
MAILCHIMP_TRANSACTIONAL_API_KEYyesAPI key

Example (Sending a Message With Mailchimp Transactional)

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

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

const  = .(function* () {
  const  = yield* ;
  return yield* .({
    : "hello@example.com",
    : "ada@example.com",
    : "Welcome",
    : "Your account is ready.",
  });
});

.(.(.()));

Use a from address your Mailchimp Transactional account is allowed to send from.

Options

MailchimpTransactional.layer takes these options. layerConfig builds the same object from a Config.

Prop

Type

Capabilities

Mailchimp Transactional reports this in email.capabilities:

TextHTMLBothSender nameCcBccReply-toHeadersAttachmentsInline imagesIdempotency
yesyesyesyesyesyesmultipleyesyesnono

These fail with UnsupportedFeatureError and acceptance: "notSubmitted" before any request:

  • An attachment with a contentId (feature inlineAttachments).
  • An idempotencyKey (feature idempotency).

Idempotency

Not supported. A key fails with UnsupportedFeatureError before sending.

Provider notes

  • Recipients are sent with preserve_recipients: true, so every to, cc and bcc recipient is listed in the message headers each recipient sees.
  • Mailchimp answers per recipient. The statuses sent, queued and scheduled count as accepted, and rejected and invalid as rejected. Any other status fails with UnexpectedResponseError.
  • When some recipients are rejected the receipt is partiallyAccepted with one outcome per recipient. When all are rejected the send fails with MessageRejectedError. A hard_bounce reject reason is kept as rejectionCode.

Using your own client

layerClient takes any object with messages.send(body), which the client returned by the SDK has. options is optional.

Example (Borrowing a Mailchimp Transactional Client)

import mailchimp from "@mailchimp/mailchimp_transactional";
import * as MailchimpTransactional from "@effect-kit/emails/mailchimp-transactional";

const client = mailchimp("fake-key");

const EmailLive = MailchimpTransactional.layerClient(client);

You own a borrowed client. The Layer never closes it, and the client keeps its own retry, timeout and logging policy.

Errors

ProviderConfigurationError carries provider: "mailchimp-transactional" and a field naming the bad option. Layer construction fails with it, and layerClient fails with it for the client options.

fieldRaised when
timeoutThe timeout is not finite and positive.
tokenThe API key is not printable ASCII without spaces.
baseUrlThe URL is not http or https, or has credentials, a query or a fragment.
Mailchimp responseReason
status: "error" with name Invalid_KeyAuthenticationError
status: "error" with name PaymentRequiredQuotaExceededError
Every recipient rejected or invalidMessageRejectedError

Other status: "error" responses fail with ProviderError and acceptance: "rejected". The error name is kept as providerCode only for the two names above.

Any other HTTP status uses the shared mapping: 401 is AuthenticationError, 403 PermissionDeniedError, 429 RateLimitedError, 400 and 422 InvalidMessageError, 5xx ProviderUnavailableError, and anything else ProviderError. acceptance is rejected for a 4xx status other than 409 and unknown otherwise. See Errors. A network failure with no status is TransportError, and ETIMEDOUT or ECONNABORTED is TimeoutError, both with acceptance: "unknown".