Mailer SMTP Configuration
TL;DR
New projects send mail over SMTP through <Api.Mailer.Smtp /> from webiny/extensions, which webiny.config.tsx renders. It comes with the webiny package, so there is nothing to install. Without props, the settings are entered in the Admin app under Settings > Mailer. With props, they come from code and the settings screen shows them read-only. The props are serialized into the build artifact, so always pass the password through an environment variable, never hard-code it. Deploy the API after making changes.
To send through Resend, SendGrid or Amazon SES instead, replace <Api.Mailer.Smtp /> with that provider's component (see webiny-mailer-providers).
Core Pattern
import { 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, in place of the <Api.Mailer.Smtp /> the project template added. Set all of host, port, user, password and from, or none of them.
Props Reference
| 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 |
\* Required when settings are set in code. Leave every prop out to enter the settings in the Admin app instead; port, user, password and from follow the same rule as host.