Configuring Keycloak SMTP and email verification
Keycloak can send emails for account verification, password resets, and other notifications. This requires configuring an SMTP server in the Keycloak admin console.
Setting up the SMTP server
-
Log in to the Keycloak admin console and select your application realm
-
Navigate to
Realm settings→Email -
Fill in the SMTP server details:
| Field | Description |
|---|---|
| From | The sender email address (e.g. no-reply@example.com) |
| Host | SMTP server hostname |
| Port | SMTP port (typically 587 for STARTTLS, 465 for SSL) |
| Encryption | Enable StartTLS or SSL/TLS as required by your server |
| Authentication | Enable and provide credentials if your server requires them |
- Click
Test connectionto verify the configuration, thenSave
See the Keycloak email configuration documentation for the full list of options.
Requiring email verification
Once SMTP is configured, you can require new users to verify their email address before they can log in:
-
Navigate to
Realm settings→Login -
Enable
Verify email -
Click
Save
From this point on, newly registered users will receive a verification email and must click the link before their
account becomes active. Existing users can be sent a verification request manually from Users → select a user →
Actions → Send verify email.
Refer to the Keycloak login settings documentation for additional options such as requiring email as username.
Making email required in the user profile
You can enforce that users always provide an email address by marking it as required in the user profile schema:
-
Navigate to
Realm settings→User profile -
Click on the
emailattribute to edit it -
Under
Required field, enableAlways(or scope it to specific roles if needed) -
Click
Save
With this setting, users cannot complete registration or profile updates without supplying an email address. Combined
with the Verify email login setting above, this ensures every active account has a confirmed email address.
See the Keycloak user profile documentation for further details on attribute constraints and validation rules.