automated email testing

Automating password reset tests with long-polling email APIs

Ditch custom sleep loops and flaky retry logic by holding open a single HTTP request while testing your forgot-password email flows.

By Douglas Mims·September 12, 2026·4 min read
What matters here
  1. Long polling eliminates flaky retry loops by keeping a single HTTP connection open for up to 180 seconds.
  2. Real MX inboxes process password reset emails through standard mail routing rather than local SMTP mocks.
  3. Filtering long-polling requests by subject line isolates password reset tokens instantly in test suites.

The Problem with Polling for Password Reset Emails

Automating a password reset flow usually introduces test flakiness. Your test clicks a forgot password button, triggering an asynchronous background job on your backend. The backend renders a template, signs a token, and dispatches the message to a mail server. Meanwhile, your test runner needs to know when that specific email actually arrives.

Most engineering teams solve this with brittle workarounds. They insert hardcoded delays like sleep statements, hoping five seconds is enough time for the queue to process. When mail delivery takes six seconds, the test suite crashes. Other teams build custom retry loops with exponential backoff timers. This adds dozens of lines of utility code to maintain across test repositories. If backoff parameters are misconfigured, tests either hit API rate limits or time out prematurely.

Replacing Retry Loops with Single Long-Polling Requests

Long polling eliminates custom retry loops by moving the waiting logic to the HTTP request itself. Instead of repeatedly querying an inbox every few hundred milliseconds, your test runner opens a single request and instructs the server to hold the connection open until an email matches specific criteria.

InboxRhino handles this pattern through its wait-for-message endpoint using the wait_seconds query parameter. You can instruct the API to hold a request open for up to 180 seconds. The server blocks the HTTP response until a matching message enters the inbox, returning the full parsed body immediately upon arrival.

Step-by-Step Walkthrough: Automating a Password Reset Test

Testing a reset flow requires coordinating three distinct actions: generating a temporary address, triggering the application password reset email, and waiting for the message to arrive.

1. Provision a Real MX Test Inbox

Start by creating a fresh test address via the API. This ensures isolated state for every test run so legacy messages never corrupt your assertions.

Make an HTTP POST request to https://api.inboxrhino.in/v1/inboxes with your bearer token. The API returns an inbox object containing a unique identifier and an address on test.inboxrhino.in. Because these addresses process inbound mail through real MX records, your application tests against actual network delivery paths rather than local SMTP mocks.

2. Trigger the Forgot Password Action

Pass the freshly generated email address directly into your application password reset form or API endpoint. Your backend queue picks up the request and dispatches the reset link to the real MX server.

3. Hold the API Request Until Delivery

Instead of polling inside a custom retry loop, make a single HTTP GET request to fetch messages from https://api.inboxrhino.in/v1/inboxes/{inbox_id}/messages with the parameters wait_seconds=180, limit=1, include=content, and subject=Reset.

This request stays active until the email arrives or the 180-second window elapses. Filtering by parameters like subject line ensures you isolate password reset communications from generic onboarding or transactional notices.

4. Extract the Link and Complete the Flow

When the long-polling request completes, the JSON response includes the parsed email content. Extract the reset link or temporary security code directly from the HTML or plain text body. Your test runner can then navigate to that link, set a new password, and verify that the authentication state updates successfully.

Visual Debugging and Security Sandboxing

Automated assertions on JSON payloads catch structural errors, but human visual inspection remains critical when debugging test failures. When a password reset test fails in continuous integration pipelines, developers need to verify whether the email rendered broken markup, omitted the button link, or failed CSS layout rules.

InboxRhino includes a built-in web console with a sandboxed HTML viewer. To prevent malicious or malformed test content from affecting your local browser environment, the viewer strictly blocks scripts, active HTML forms, browser popups, and remote images. This allows QA teams to safely inspect raw email rendering without risking cross-site scripting vulnerabilities in their browser sessions.

Working Within Quotas and System Constraints

Integrating long-polling email tests into automated test suites requires awareness of system limits and environment architecture:

  • Receive-Only Architecture: Test inboxes are strictly receive-only. They cannot send outbound mail, reply to messages, or forward emails. Your application must initiate all communications.
  • Retention Limits: Inbound messages are retained for 30 days before automatic deletion. The inbox address itself remains active until manually deleted.
  • Free Tier Quotas: The live free tier permits 11 active inboxes, up to 33 inbound emails per UTC calendar month, and 1 organization user. This provides sufficient headroom to wire up local integration suites and core password reset flows.
  • Paid Tiers: Paid plans with higher limits and INR pricing, including Starter, Growth, and Scale, are marked as coming soon.

Cleaner Test Suites with Long Polling

Replacing custom polling routines with direct long-polling requests keeps test code clean and deterministic. By holding connections open for up to 180 seconds, test runners avoid unnecessary HTTP overhead, eliminate artificial sleep delays, and reliably capture password reset emails as soon as they hit real MX servers.

More from InboxRhino News