Self-service operations, such as resetting one’s own password, getting forgotten usernames, and others, require access to email. Mailhog is a lightweight utility for sending and viewing email messages in a Kubernetes cluster, especially for development and test purposes.
Note: Mailhog is not meant for use in production environments.
ForgeRock does not guarantee the individual success developers may have in implementing the code on their development platforms.
Set up Mailhog in your Kubernetes cluster
- You have set up the CDK and your Kubernetes context is set to your CDK cluster.
- You have installed Helm 3.
- Set up your Kubernetes context and namespace. For example:
- Install Mailhog in your namespace using Helm 3:
- Verify that the Mailhog pod is running:
- Optional: To verify delivery of SMTP messages, set up port forwarding on SMTP port 1025 using a terminal window:
- To view the emails received on the Mailhog server, set up port forwarding on HTTP port 8025 using another terminal window:
- Log in to the IDM administration console and configure email settings.
- In a web browser, access the reset password service in your deployment. For example: https://my-namespace.iam.example.com/am/?service=ResetPassword.
- Enter the email ID of the user whose password needs to be reset. For example, the email ID for our test user is [email protected]e.com.
- A notification appears indicating that an email has been sent to the address you entered.
- View your Mailhog inbox to see if you have received an email to reset the password.
- Open the reset your password email and click the Reset Password link.
- Enter the new password.
- Verify that you can log in after you have reset the password.
- In a web browser, access the reset password service in your deployment. For example: https://my-namespace.iam.example.com/am/?service=ForgottenUsername.
- Enter the email ID of the user whose username you want to obtain. For example, the email ID for our test user is [email protected]
- A notification appears indicating an email has been sent.
- View your Mailhog inbox to see if you have received the Account Information - username email.
- Click the login link and log in with the username you received in the email.
- Log in with the obtained username and the password.
- Verify that you are able to log in as the user.
kubectl ctx minikube kubectl ns my-namespace
helm repo add codecentric https://codecentric.github.io/helm-charts helm install mailhog codecentric/mailhog
kubectl get pods | grep mailhog mailhog-16...zl 1/1 Running 1 23m
export POD_NAME=mailhog-16...zl kubectl port-forward --namespace my-namespace $POD_NAME 1025
export POD_NAME=mailhog-16...zl kubectl port-forward --namespace my-namespace $POD_NAME 8025
Enable the email service in IDM
After verifying that the Mailhog server is able to send and receive messages, you can configure email settings in the IDM server:
Reset a user’s password
Obtain a forgotten username
There you have it, a simple way to set up mailhog, and the test password reset and forgotten username in a development environment.