How to validate email verification codes and links

When testing email verification flows, Magic Inspector provides built-in capabilities to catch and validate verification codes and links sent via email.

Understanding Magic Inspector's Email Server

Magic Inspector includes a built-in email server that you can use to receive test emails. To use this server, your test email addresses must follow this pattern:

  • Must end with @email.magicinspector.com
  • Can include any prefix, e.g. my-company@email.magicinspector.com
  • Can include variables for dynamic addresses, e.g. your-company_{{mock.int}}@email.magicinspector.com

The server actively listens for incoming emails to these addresses. You can then use the Get email verification code or Get email link actions to capture verification codes or links from these emails.

Security Best Practices

Since this is a shared email server, it's important to note:

  • Anyone can send an email to the same email address that you're testing with
  • As a consequence, it's recommended to use unguessable email addresses by either:
    • Including random variables like {{mock.int}}
    • Embedding a secret in the email address

Pro Tip: Generating Dynamic Email Addresses

If you follow the security best practices mentioned above, you can generate dynamic email addresses using the "Generate value" instruction.

This instruction will help you generate a random email address and store the result in Variables > Previous Results. You can then reference this email address in your test.

  1. Use the "Generate value" instruction with your desired email pattern
Generate value instruction
  1. The generated email address is stored in Variables > Previous Results
  2. Reference this email throughout your test for consistency
Reuse generated email address

Get Email Verification Code Action

This action helps you extract verification codes from incoming emails. Here's how it works:

  1. Provide the target email address as an argument (must be a @email.magicinspector.com address)
  2. The action waits for an email containing a verification code
  3. Once received, the AI automatically extracts the code
  4. The code is stored in Variables > Previous Results
  5. You can then use this code in subsequent actions, like filling in a verification form
Get email verification code action

This action is similar to the verification code action, but for capturing links.

Here's how it works:

  1. Provide the target email address
  2. Specify the type of link you're expecting in natural language (e.g. "Reset password link", "Signup link")
  3. The action waits for an email containing a matching link
  4. Once found, the link is stored in Variables > Previous Results
  5. You can use this link in later actions like navigation or validation
Get email link action

Was this page helpful?