createEmailClient
createEmailClient(
config):EmailClient
Defined in: packages/email/src/create-email-client.ts:35
Create an email client that renders react-email templates and delivers them through a pluggable EmailProvider.
The client renders the React element to both HTML and plain-text via
@react-email/render, resolves the provider and sender address (supporting
lazy getters for Workers compatibility), and delegates delivery.
Parameters
Section titled “Parameters”config
Section titled “config”Client configuration with provider and default sender.
Returns
Section titled “Returns”An EmailClient with a send method.
Example
Section titled “Example”import { createEmailClient } from "@cfast/email";import { mailgun } from "@cfast/email/mailgun";
const email = createEmailClient({ provider: mailgun(() => ({ apiKey: env.get().MAILGUN_API_KEY, domain: env.get().MAILGUN_DOMAIN, })), from: () => `MyApp <noreply@${env.get().MAILGUN_DOMAIN}>`,});
await email.send({ to: "user@example.com", subject: "Welcome", react: <WelcomeEmail name="Daniel" />,});