Preview: SendMock has no stable release yet. These docs follow develop.
SendMock
Recipes

Read a one-time code

Read a sign-up or login code from an email, an SMS or Twilio Verify, by hand or from a test.

Try it in the demo.

The situation: your app sends a one-time code by email or SMS. You need the code to finish the flow, by hand while developing and from your end-to-end tests.

You need: your app's mail or SMS settings pointing at SendMock. See Connect your app.

Steps

  1. Trigger the code in your app (sign up, log in, confirm a phone number).
  2. In SendMock, open the email in Mail, the conversation in SMS, or the verification in SMS > Verify.
  3. The code is shown on its own with a copy button (Copy code 482913). Paste it into your app.

In a test

# waits until a code arrives, then prints it
sendmock otp --to [email protected] --wait 10s
sendmock otp --to +8801700000000 --channel sms --wait 10s

Agents use the sendmock_otp_get MCP tool the same way.

When no code is found

SendMock finds codes with the patterns in Settings > OTP patterns. If your app writes codes differently (for example ABC-123), add a pattern: Advanced: OTP patterns.

In your code

A test that signs up, waits for the emailed code and finishes the sign-up with it. For an SMS code, pass the phone number as to and sms as channel.

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: sign up as [email protected]

otp=$(sendmock otp --to [email protected] --wait 10s --json)

# In your app: enter the code

jq -e '.channel == "email"' <<<"$otp" >/dev/null

What you should see

The code beside the message, and the same code from sendmock otp.

Try it in the demo

  1. Open Mail and click Your verification code.
  2. The code 482913 shows under the header with Copy code 482913.

Next

On this page