Files
HiveGrid-Wireframes/hivegrid-cloud/packages/mail/README.md
T

41 lines
1.5 KiB
Markdown

# @toolctrl/mail
Source-only mail provider boundary for queued transactional delivery.
This package provides the Mailjet adapter used by the worker mail runtime. Web and API code enqueue transactional mail jobs; they do not read provider credentials or call Mailjet directly.
## Provider Boundary
`MailProvider` exposes one delivery method:
```ts
import { createMailjetProviderFromEnv } from "@toolctrl/mail";
const mail = createMailjetProviderFromEnv();
await mail.send({
to: ["user@example.com"],
subject: "Welcome",
text: "Thanks for signing up.",
});
```
The Mailjet adapter uses the built-in `fetch` API and the Send API v3.1 `POST /v3.1/send` endpoint with HTTP Basic Auth (`base64(MAILJET_API_KEY:MAILJET_SECRET_KEY)`). There is no Mailjet SDK dependency.
## Environment
Required in the worker environment when Mailjet delivery is enabled:
| Variable | Purpose |
| --- | --- |
| `MAILJET_API_KEY` | Mailjet public API key (Basic-Auth username). |
| `MAILJET_SECRET_KEY` | Mailjet private/secret API key (Basic-Auth password). |
| `MAILJET_FROM_EMAIL` | Default sender email from a verified Mailjet sender domain. |
| `MAILJET_FROM_NAME` | Optional default sender display name. |
## Runtime Boundary
- Web/API transactional send paths enqueue `toolctrl.email` jobs through `@toolctrl/queue`.
- Worker handlers instantiate `createMailjetProviderFromEnv` and deliver queued jobs.
- Do not add provider credentials, SDKs, or direct Mailjet calls to route modules.