# Email Testing with Mailosaur
Source: https://www.jetify.com/docs/docs/testpilot/guides/email-testing-mailosaur

Test email registration and verification flows with Mailosaur. Generate email addresses, retrieve OTP codes, and verify email content.

## How It Works[​](#how-it-works "Direct link to How It Works")

When your tests need an email address, Testpilot can:

1. Automatically generate a unique Mailosaur email address
2. Use this email to receive real emails during test execution
3. Access the inbox to retrieve verification codes, magic links, or other information
4. Complete the authentication or verification flow automatically

## Setup[​](#setup "Direct link to Setup")

### 1. Create a Mailosaur Account[​](#1-create-a-mailosaur-account "Direct link to 1. Create a Mailosaur Account")

If you don't already have one, [sign up for a Mailosaur account](https://mailosaur.com/sign-up/) and
retrieve your API credentials. You will need a Mailosaur API Key and Server ID to configure
Testpilot.

### 3. Set Environment Variables[​](#3-set-environment-variables "Direct link to 3. Set Environment Variables")

Configure Testpilot to use your Mailosaur account by setting these environment variables:

```bash theme={null}
export MAILOSAUR_API_KEY=your_api_key
export MAILOSAUR_SERVER_ID=your_server_id
```

In CI environments, add these to your secure environment variables.

## Using Generated Emails in Tests[​](#using-generated-emails-in-tests "Direct link to Using Generated Emails in Tests")

Once configured, Testpilot will automatically handle email generation. You don't need to explicitly
specify email addresses in your test scenarios - Testpilot will generate and use them as needed. For
example, you can test a signup flow using a unique, randomly generated email as shown below:

### Example Test Scenario[​](#example-test-scenario "Direct link to Example Test Scenario")

```yaml theme={null}
cases:
  id: email_signup_0001
  name: Sign up with email verification
  description: Use a random email to test the signup flow
  url: https://zillow.com/signup
  steps:
    - Click Create Account
    - Enter an email address to signup for an account
    - Enter a password
```

## Manually Specifying Email Addresses

If you prefer not to use the Mailosaur integration, you can explicitly specify email addresses in your test scenarios:

```yaml theme={null}
cases:
  id: email_signup_0001
  name: Sign up with email verification
  description: Use a random email to test the signup flow
  url: https://zillow.com/signup
  steps:
    - Click Create Account
    - Sign up for an account with email address "test123@example-email.com"
    - Enter a password
```

Note that without Mailosaur integration, Testpilot won't be able to automatically check inboxes or
handle email verification flows, unless you design a test case specifically for this workflow.