Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when configuring SMTP email/mailer settings in a Webiny project. Triggers on: "configure email", "set up SMTP", "mailer config", "sending emails", "email not working", "configure mailer", "SMTP password", "Api.Mailer.Smtp".
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -32% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -7% | 0% |
| case-03 | ✗→✓ | ▲ Improved | -21% | 0% |
| case-06 | ✗→✓ | ▲ Improved | -30% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 27% | 0% |
Add <Api.Mailer.Smtp ... /> to your webiny.config.tsx to configure SMTP email delivery at build time. The component serializes the settings into the build artifact — always pass the password via an environment variable, never hard-code it. Deploy the API after making changes.
tsximport { Api } from "webiny/extensions"; <Api.Mailer.Smtp host={"smtp.example.com"} port={587} user={"smtp-user"} password={process.env.SMTP_PASSWORD!} from={"noreply@example.com"} replyTo={"support@example.com"} {/* optional */} />
Place this inside the JSX returned by your config component in webiny.config.tsx, alongside other <Api.*> extensions.
| Prop | Type | Required | Description | | ---------- | -------- | -------- | ---------------------------------------------- | | host | string | Yes | SMTP server hostname | | port | number | Yes | SMTP server port (positive integer) | | user | string | Yes | SMTP authentication username | | password | string | Yes | SMTP authentication password — use env var | | from | string | Yes | Default sender address | | replyTo | string | No | Default reply-to address |
from and replyTo are validated by the email-addresses package against RFC 5322.
webiny.config.tsx)tsximport React from "react"; import { Api, Admin, Core } from "webiny/extensions"; const MyConfig = () => { return ( <> {/* ... other extensions ... */} {/* Mailer: configure SMTP transport via code */} <Api.Mailer.Smtp host={"smtp.sendgrid.net"} port={587} user={"apikey"} password={process.env.SENDGRID_API_KEY!} from={"noreply@acme.com"} replyTo={"support@acme.com"} /> </> ); };
Add SENDGRID_API_KEY=your-secret to your .env file (never commit it).
| Mistake | Fix | | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | | Hard-coding the password | Use process.env.SMTP_PASSWORD! | | process.env.SMTP_PASSWORD undefined at build time → "expected string, received object" error | Ensure the env var is set before deploying | | from/replyTo value fails validation | Must be a valid RFC 5322 mailbox address | | Settings not taking effect | Run yarn webiny build api after editing webiny.config.tsx |
bash# After editing webiny.config.tsx, build the API yarn webiny build api
> Note: This command only works in a dev environment. For other environments, run yarn webiny build api --env=YOUR_ENV instead.
ts// Environment variable in .env SMTP_PASSWORD = your - smtp - password - here;
webiny-project-structure — Where webiny.config.tsx lives and how extensions are structuredwebiny-local-development — Running and deploying locallyOther measured skills in the registry, with their headline benchmark lift.