All use cases
OTP

OTP Verification

Auto-extract and verify 2FA/MFA confirmation codes

MailBrew's unique OTP auto-extraction API automatically parses verification codes from email bodies. No regex needed. Supports 6-digit codes, alphanumeric codes, magic links, and other major OTP patterns.

Why MailBrew for this use case

01

One-call OTP extraction

Dedicated endpoint /emails/{id}/otp auto-extracts verification codes from email body. No regex writing required.

02

Multiple format support

Auto-recognizes 6-digit numeric, alphanumeric, magic links, and other major OTP patterns.

03

2FA/MFA test automation

Fully automate two-factor authentication in login flows. No manual code entry needed.

04

Security requirement validation

Perfect for testing OTP expiration, resend limits, brute-force protection, and other security requirements.

Sample code

Python

Python
import mailbrew

client = mailbrew.Client("mb_your_key_here")

# 1. Create a test address
addr = client.addresses.create(ttl=300)

# 2. Trigger login in app → sends OTP email
trigger_login(email=addr.address)

# 3. Auto-extract OTP (no regex needed!)
emails = client.addresses.emails(addr.address)
otp = client.addresses.otp(addr.address, emails[0].id)
print(otp)  # => { "code": "847291", "type": "numeric", "digits": 6 }

# 4. Complete login with extracted OTP
complete_login(code=otp["code"])

Ready to try this use case?

Get started with the free plan today. No credit card required.

Create free account