From Header Mismatch

Error Message

From: Header does not match the sender's domain

This error occurs when the From: header in your email doesn't match your verified domain in Mailtrap.

The Requirement

To send email with Mailtrap, your From: header must match your verified domain.

Example: If your verified domain in Mailtrap is acme.com, your From: address must be {anything}@acme.com.

If you're sending from a subdomain like mail.acme.com, your From: address must match that subdomain exactly.

Common Causes

1. Unverified Domain

Your domain hasn't been added or verified in Mailtrap yet.

Solution:

  1. Add your domain

  2. Complete the DNS verification process

2. Envelope From vs Header From Mismatch

In some frameworks (like Laravel), the MAIL_FROM_ADDRESS variable is used for the envelope from address, but it's not the same as the header From: address.

3. Subdomain Confusion

If you verified example.com but are trying to send from mail.example.com, you need to verify the subdomain separately.

How to Fix

1

Verify Your Domain

First, check if your domain has been added to your Mailtrap account.

  1. Look for your domain in the list

  2. Ensure it has the Verified badge

If not verified, complete the DNS setup process.

2

Check Your Email Configuration

Ensure your email message has a From: header that contains an address on your verified domain.

Example for Laravel:

Make sure MAIL_FROM_ADDRESS uses your verified domain.

3

Verify Envelope From Matches Header From

Most likely, the envelope from address is set separately from the header. Make sure they match.

For Laravel specifically:

  • Check that MAIL_FROM_ADDRESS in your .env file matches your verified domain

  • Verify this address is used in both the envelope and header

4

Test Your Configuration

Send a test email and verify:

  • The From: header shows your verified domain

  • The envelope from (visible in email headers) matches

  • No errors appear in your logs

Framework-Specific Examples

Laravel

In your .env file:

Ensure MAIL_FROM_ADDRESS uses your verified domain.

Other Frameworks

The principle is the same across all frameworks:

  1. Set your From: address to use your verified domain

  2. Ensure both envelope and header from addresses match

  3. Verify the domain in Mailtrap before sending

Still Having Issues?

If you've verified your domain and updated your configuration but still see this error:

  • Check your email sending code for hardcoded From: addresses

  • Look for middleware or plugins that might be modifying the From: header

  • Review your framework's documentation for email configuration

  • Contact support at [email protected]

Last updated

Was this helpful?