I'm on a Mac, and I'm trying to get Keycloak 24.0.2 (running as a Docker container) to send emails as part of User Registration. I have Mailhog running locally and I have configured Keycloak to send emails to it, and have successfully tested that connection:
So I know Keycloak can send email to Mailhog.
In the Keycloak Realm Settings >> Login tab, I enable User Registration:
When I open my app and go to an authenticated page, it correctly redirects me to the Keycloak Login screen, and I can now see a Register link at the bottom:
So far, so good. I click "Register" and proceed to fill out the Registration form:
I click "Register" and I am correctly redirected back into my app.
In Keycloak, I see the new user registration event:
When I click into the REGISTER event, I see the new user that was created:
However, when I refresh my screen in Mailhog, I see no emails were sent. Furthermore, if I look at the Keycloak logs (vid docker logs
) I see no log output, errors, etc.
Is there anything I need to do to configure Keycloak to send emails when a new user registers? Did I forget any steps at all? If not, can anyone spot where I'm going awry, or lend ideas for troubleshooting?
I got this working, after reaching out to the Keycloak team on Slack, who provided excellent support!
I had forgotten to enable Verify email under Realm Settings >> Email Settings
.
So that takes care of sending emails when the user self-registers.
To get email sending working when an Admin creates a new user in the Keycloak admin console/UI, it was a bit trickier, but I got it working as well:
Required user actions
dropdownCredentials
tabI'm not in love with that work flow, because it requries the admin to send the user their temp/permanent password somehow prior to them logging in for the first time. But with Keycloak's REST API I believe I will find a way to use the same endpoints under the hood but to create a more UX-focused, homegrown "invite new user" feature.