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
- Including random variables like
Customers on the Magic Inspector Enterprise plan can have dedicated email servers for their tests, feel free to contact us to learn more about this.
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.
- Use the "Generate value" instruction with your desired email pattern
- The generated email address is stored in Variables > Previous Results
- Reference this email throughout your test for consistency
Get Email Verification Code Action
This action helps you extract verification codes from incoming emails. Here's how it works:
- Provide the target email address as an argument (must be a
@email.magicinspector.com
address) - The action waits for an email containing a verification code
- Once received, the AI automatically extracts the code
- The code is stored in Variables > Previous Results
- You can then use this code in subsequent actions, like filling in a verification form
Get Email Link Action
This action is similar to the verification code action, but for capturing links.
Here's how it works:
- Provide the target email address
- Specify the type of link you're expecting in natural language (e.g. "Reset password link", "Signup link")
- The action waits for an email containing a matching link
- Once found, the link is stored in Variables > Previous Results
- You can use this link in later actions like navigation or validation