ZeptoMail
Send email through ZeptoMail with the @effect-kit/emails/zeptomail Layer.
The @effect-kit/emails/zeptomail subpath sends messages through ZeptoMail and provides the Email service.
Installation
npm install @effect-kit/emails effect zeptomail@8.0.1The SDK is a pinned optional peer. It is needed only when you import this subpath.
Setup
ZeptoMail.layerConfig() reads these variables:
| Variable | Required | Value |
|---|---|---|
ZEPTOMAIL_TOKEN | yes | Send mail token |
ZEPTOMAIL_URL | yes | Full API URL, for example https://api.zeptomail.com/v1.1/email |
Example (Sending a Message With ZeptoMail)
import { , , } from "effect";
import { } from "@effect-kit/emails";
import * as from "@effect-kit/emails/zeptomail";
const = .().(
.(.(.())),
);
const = .(function* () {
const = yield* ;
return yield* .({
: "hello@example.com",
: "ada@example.com",
: "Welcome",
: "Your account is ready.",
});
});
.(.(.()));Use a from address your ZeptoMail account is allowed to send from.
Options
ZeptoMail.layer takes these options. layerConfig builds the same object from a Config.
Prop
Type
Capabilities
ZeptoMail reports this in email.capabilities:
| Text | HTML | Both | Sender name | Cc | Bcc | Reply-to | Headers | Attachments | Inline images | Idempotency |
|---|---|---|---|---|---|---|---|---|---|---|
| yes | yes | yes | yes | yes | yes | multiple | yes | yes | yes | no |
These fail with UnsupportedFeatureError and acceptance: "notSubmitted" before any request:
- An
idempotencyKey(featureidempotency).
Idempotency
Not supported. A key fails with UnsupportedFeatureError before sending.
Provider notes
urlhas no default because the host depends on the Zoho data centre of your account. BothlayerConfigandlayerneed it.- The package adds the
Zoho-enczapikeyprefix to the token, so pass only the token. - ZeptoMail returns a request id and no message id. The receipt's
referencesis empty andrequestIdholds the request id.
Using your own client
layerClient takes any object with sendMail(message), which a SendMailClient has. options is optional.
Example (Borrowing a ZeptoMail Client)
import { SendMailClient } from "zeptomail";
import * as ZeptoMail from "@effect-kit/emails/zeptomail";
const client = new SendMailClient({
url: "https://api.zeptomail.com/v1.1/email",
token: "Zoho-enczapikey fake-token",
});
const EmailLive = ZeptoMail.layerClient(client);You own a borrowed client. The Layer never closes it, and the client keeps its own retry, timeout and logging policy. A borrowed client carries its own token, so include the prefix there if the SDK needs it.
Errors
ProviderConfigurationError carries provider: "zeptomail" and a field naming the bad option. Layer construction fails with it, and layerClient fails with it for the client options.
field | Raised when |
|---|---|
timeout | The timeout is not finite and positive. |
token | The token is not printable ASCII without spaces. |
url | The URL is not http or https, has credentials, a query or a fragment, or its path is not /v1.1/email. |
| ZeptoMail failure | Reason |
|---|---|
| SDK network error | TransportError |
| SDK timeout error | TimeoutError |
| SDK authentication error | AuthenticationError (acceptance: "rejected") |
| SDK validation error, or a local validation string | InvalidMessageError (acceptance: "notSubmitted") |
Error code TM_3004 | InvalidMessageError (acceptance: "rejected") |
| Any other error code in the response | ProviderError (acceptance: "rejected") |
An API error from the SDK uses its HTTP status with the shared mapping. A response that is not valid JSON fails with UnexpectedResponseError. Kept providerCode values are TM_3004 and AUTHENTICATION_ERROR.