Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eleven0's avatar

RFC 2822, 3.6.2 - Email Problem Only on Staging Server

I have a problem on my staging environment while the problem does not occur in my local env.


        ->from(env('MAIL_FROM_ADDRESS'), "$user->firstname $user->lastname")

it gives me following error;

(1/1) Swift_RfcComplianceException
Address in mailbox given [] does not comply with RFC 2822, 3.6.2.

It seems that app is not able to get the mail_from_address from my .env file. Why is this happening as everything works fine in my local environment?

I have these in my deploy script as well,

composer dump-autoload

# Clear caches
php artisan cache:clear
php artisan auth:clear-resets

php artisan config:clear
php artisan config:cache
php artisan view:clear

What am I missing here? Any suggestion?

0 likes
2 replies
bobbybouwmann's avatar

If you look closely at the error you can see that it tries to send to an empty email

Address in mailbox given [] does not comply with RFC 2822, 3.6.2.

So the problem here is that you cache your config. Whenever you cache your config, Laravel won't read the env values directly anymore. Instead it will combine all config files to one and fetch the data from there.

So if you want to have config caching you have to use the config instead

->from(config('mail.from.address'), "$user->firstname $user->lastname")

Source: https://github.com/laravel/laravel/blob/master/config/mail.php#L59

Let me know if that works for you!

eleven0's avatar

I moved config:cache before config:clear in my deploy script and app was able to get the email address from .env file. It was returning null.

Please or to participate in this conversation.