Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Laravel mail fails with 550 5.7.1 Relaying denied

ErrorExpected response code "250/251/252" but got code "550", with message "550 5.7.1 Relaying denied"

Short answer

The SMTP server you connected to refused to deliver your message, because it does not accept mail from you for that recipient. In Laravel this usually means the mailer talks to the wrong server or sends without login, or uses a From address the account may not send as. Check MAIL_HOST, the login and MAIL_FROM_ADDRESS.

  • Applies to Laravel 12, PHP 8.3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the mail configuration Laravel really uses. If you ran config:cache, the .env file is no longer read, so this shows the truth.

    php artisan config:show mail
    grep -n '^MAIL_' .env
  2. 2Match what you see, then jump to its fix

    1. 1MAIL_HOST is the default 127.0.0.1, or a hostname of a server that is not your mail providerThe mailer points at a server that does not relay for youFix
    2. 2MAIL_USERNAME and MAIL_PASSWORD are empty in .envNo SMTP login is sentFix
    3. 3550 5.7.1 only for some From addresses or some recipient domainsThe sender or recipient is not allowed for this accountFix

What does the error look like?

  • Expected response code "250/251/252" but got code "550", with message "550 5.7.1 Relaying denied"
  • Mail works to some recipients and fails with 550 for others

Cause 1 of 3

The mailer points at a server that does not relay for you

1Check

Laravel's stock smtp mailer reads MAIL_HOST (default 127.0.0.1) and MAIL_PORT (default 2525). A local or foreign server that is not set up to relay for your app answers with a relay refusal.

grep -n '^MAIL_' .env

2Fix

Set MAIL_HOST and MAIL_PORT to the values your mail provider documents for SMTP submission.

MAIL_MAILER=smtp
MAIL_HOST=smtp.your-provider.example
MAIL_PORT=587

3Verify

Clear the cached config, then trigger one real email from the app. The 550 is gone or replaced by a more specific error.

php artisan config:clear && php artisan config:show mail

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 3

No SMTP login is sent

1Check

The smtp mailer takes its login from MAIL_USERNAME and MAIL_PASSWORD, and both default to empty. A server whose policy requires authentication will not accept the message from an unauthenticated client (RFC 4954 describes this policy through reply 530 5.7.0, and some servers use a relay refusal instead).

grep -n '^MAIL_USERNAME\|^MAIL_PASSWORD' .env

2Fix

Add the SMTP username and password from your provider, then clear the cached config.

MAIL_USERNAME=your-smtp-user
MAIL_PASSWORD=your-smtp-password

3Verify

Clear the config cache, confirm the values are loaded, and send again.

php artisan config:clear && php artisan config:show mail

Confirmed by rfc-editor.org

Did this fix it?

Cause 3 of 3

The sender or recipient is not allowed for this account

1Check

Status 5.7.1 means delivery not authorized: the sender is not allowed to send to that destination, which can be the result of per-host or per-recipient filtering (RFC 3463). Compare the From address with the domain your provider has verified for this account.

grep -n '^MAIL_FROM' .env

2Fix

Send from an address on a domain verified in your mail account, or ask the provider to allow the recipient domain.

MAIL_FROM_ADDRESS=hello@your-verified-domain.example
MAIL_FROM_NAME="Your App"

3Verify

Clear the config cache, then send to one allowed and one other address.

php artisan config:clear && php artisan config:show mail

Confirmed by rfc-editor.org

Did this fix it?

How do I stop it coming back?

  • Keep MAIL_* values in .env only, and clear the config cache after every change.
  • Use a transactional mail service with a verified sending domain for production.
  • Test in staging with a log or sandbox mailer so a bad host is found before launch.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Email

Postfix refuses to send with "Relay access denied"

454 4.7.1 <user@example.net>: Relay access denied

Postfix says Relay access denied when a client asks it to deliver to a domain it does not host, and the client is neither listed in mynetworks nor logged in with SASL.

5 causes, each with a fix

Back end

composer require maatwebsite/excel fails to install

Composer says the package needs an older PHP than the one installed

Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.

3 causes, each with a fix

Back end

composer require laravel/horizon fails: ext-pcntl is missing

laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system

Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.