Password reset email
Catch your app's password reset email, check it, and follow its link to finish the reset.
Try it in the demo.
The situation: you are building or changing password reset. You want to click the reset link without a real inbox, and check the email looks right.
You need: your app's mail settings pointing at SendMock (127.0.0.1:1025). See Connect your app.
Steps
- In your app, request a password reset for any address, for example
[email protected]. - In SendMock, open Mail. The reset email is at the top.
- Open it. Under the header, the extracted panel lists the reset link with Copy link.
- Click the link (it opens in a new tab) and finish the reset in your app.
- Check the email: switch the HTML tab to Mobile width, and read the Text tab for people without HTML.
In a test
sendmock email wait --to [email protected] --subject "Reset your password" --timeout 10s
sendmock links --to [email protected]sendmock links prints the links of the latest email to that address, so a test can open the reset page.
In your code
A test that asks your app for a password reset, waits for the email and reads its reset link.
The examples call SendMock's REST API with each language's usual HTTP client and test framework. JavaScript, Go, Java, Rust, Ruby and C# use the small call helper shown under Test helper on their page in Connect your app.
# In your app: request a password reset for [email protected]
email=$(sendmock email wait --to [email protected] --subject 'Reset your password' --timeout 10s --json)
links=$(sendmock links --to [email protected] --json)
# In your app: open the first link and choose a new password
jq -e '.subject == "Reset your password"' <<<"$email" >/dev/nullWhat you should see
The email in Mail within a second, the link in the extracted panel, and your app's reset page when you open it.
Try it in the demo
- Open Mail and click Reset your password.
- The extracted panel shows
https://acme.test/reset?token=9f8e7d6cwith Copy link. - Press Mobile width to see the email at phone width.