Test your password-reset email end to end in GitHub Actions
A password reset touches four things: the form, the email, the link in it and the page the link opens. Tests usually mock the email, and that hides what breaks most often: the wrong host in the link, a token that expires too soon, a template variable that renders empty. This post tests the real email in a GitHub Actions job, with a throwaway inbox instead of a real mailbox. Disclosure: I built…
Password resetting involves four components: the form, the email, the link in the email, and the subsequent page. Traditional testing often mocks the email, which can lead to issues like incorrect host in the link, expiring tokens, or empty template variables. This article tests the real email in a GitHub Actions job using a temporary inbox, Email Blackhole.
The service is hosted and costs are noted due to the importance of CI. To set up, go to emailblackhole.io, press Copy as .env, and paste the values into your .env. SMTP_PASS and EBH_SECRET share the same value, as do SMTP_USER and EBH_ID. An API key can replace the secret for CI use. The SMTP settings are provided by the inbox, and the EBH_URL is set to https://emailblackhole.io.
The process involves pointing the app at a dummy SMTP server, reading the SMTP settings, and testing the reset link's single-use nature. The email is checked for arrival, correct subject and sender, a working link once, and expiry if applicable.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.