View on GitHub

examples

Email testing and SMS verification examples using MailSlurp and a wide range of frameworks.

HTTP ACCELQ Email OTP Test

This project demonstrates an HTTP-only email OTP signup test using MailSlurp APIs plus MailSlurp’s test application endpoints.

Canonical test definition:

The README and the Hurl file are intentionally aligned. If you change the flow, keep both in sync.

ACCELQ OpenAPI Import

You can import MailSlurp OpenAPI directly into ACCELQ:

What This Test Covers

This flow tests signup confirmation end to end:

  1. Create a real inbox email address.
  2. Submit signup to the test application.
  3. Wait for a matching email subject.
  4. Extract OTP/confirmation code with contentMatch.
  5. Confirm signup with the extracted code.
  6. Login and verify success.

Test application flow reference:

Exact canonical sequence (method + path):

  1. POST /inboxes
  2. POST /test-endpoints/sign-up
  3. POST /waitForMatchingEmails
  4. POST /emails/{emailId}/contentMatch
  5. POST /test-endpoints/confirm
  6. POST /test-endpoints/login

Test Application vs Your Application

This repository uses MailSlurp’s test endpoints (/test-endpoints/*) as a deterministic sample system under test.

You can swap those two application calls to your own service:

Keep inbox creation, wait-for-matching, and extraction calls on MailSlurp. The passing test currently expects:

Methods Used And References

MailSlurp API methods:

Test application methods used by this flow:

Prerequisites

The Makefile uses include ../.env, and supports both:

Configuration

Makefile defaults:

Override at runtime:

make test TEST_ENDPOINTS_BASE_URL=https://api.mailslurp.com TEST_PASSWORD='MyStrongPassword123!'

Run The Canonical Test

make test

This executes:

HTTP Step Snippets (Mirror of Canonical Flow)

1) Create inbox

Creates a MailSlurp inbox and captures id and emailAddress.

curl -sS -X POST "https://api.mailslurp.com/inboxes" \
  -H "x-api-key: $MAILSLURP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expiresIn":300000}'

2) Submit signup

Starts signup in the test app using form fields (@ModelAttribute flow).

curl -sS -X POST "https://api.mailslurp.com/test-endpoints/sign-up" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "emailAddress=$EMAIL_ADDRESS" \
  --data-urlencode "password=$TEST_PASSWORD"

Expected response contains:

3) Wait for matching email subject

Waits for exactly one email to arrive in the inbox where subject contains:

curl -sS -X POST "https://api.mailslurp.com/waitForMatchingEmails?inboxId=$INBOX_ID&count=1&timeout=120000&unreadOnly=true" \
  -H "x-api-key: $MAILSLURP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "matches": [
      {
        "field": "SUBJECT",
        "should": "CONTAIN",
        "value": "Please confirm your email address"
      }
    ]
  }'

4) Extract confirmation code

Uses content extraction endpoint with regex from test-application.md:

curl -sS -X POST "https://api.mailslurp.com/emails/$EMAIL_ID/contentMatch" \
  -H "x-api-key: $MAILSLURP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pattern":"Your confirmation code is \"(\\w+)\"\\."}'

Note: group 1 is captured as matches[1] in the response.

5) Confirm signup with extracted code

curl -sS -X POST "https://api.mailslurp.com/test-endpoints/confirm" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "emailAddress=$EMAIL_ADDRESS" \
  --data-urlencode "code=$CONFIRMATION_CODE"

Expected response contains:

6) Login and verify success

curl -sS -X POST "https://api.mailslurp.com/test-endpoints/login" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "emailAddress=$EMAIL_ADDRESS" \
  --data-urlencode "password=$TEST_PASSWORD"

Expected response contains: