Laravel mail fails because an address does not comply with RFC 2822
Symfony\Component\Mime\Exception\RfcComplianceException: Email "" does not comply with addr-spec of RFC 2822.Short answer
Symfony Mailer checks every address when the Address object is created. If the value is empty, null or not a plain address, it throws RfcComplianceException before any mail is sent. Dump the exact value that reaches to() or from(). It is usually an empty field or a 'Name <mail>' string passed to the wrong constructor.
Fix it fast
1Find out which cause you have
The exception message prints the offending value between the quotes. Read it first, then log the variable that feeds the address.
// just before Mail::to(...) logger()->info('mail recipient', ['to' => $user->email]);2Match what you see, then jump to its fix
- 1
The message shows Email "" with nothing between the quotesThe address variable is empty or nullFix - 2
The quoted value contains angle brackets and a display nameA 'Name <email>' string was given to the Address constructorFix - 3
The address contains accented or non-Latin characters and the failure appears when the server is contactedA non-ASCII address and an SMTP server that does not support itFix
- 1
What does the error look like?
Symfony\Component\Mime\Exception\RfcComplianceException: Email "" does not comply with addr-spec of RFC 2822.Email "Jane Doe <jane@example.com>" does not comply with addr-spec of RFC 2822.
Cause 1 of 3
The address variable is empty or null
1Check
Symfony's Address class trims the string and then validates it. It has no special case for an empty value, so an empty string fails the same check as a bad one.
// in tinker
User::whereNull('email')->orWhere('email', '')->count();2Fix
Make sure the value exists before you send, and validate it where the data enters the system.
if (filled($user->email)) {
Mail::to($user->email)->send(new OrderShipped($order));
}3Verify
Send to a user with an email address.
php artisan tinker --execute="Mail::to('test@example.com')->send(new App\Mail\OrderShipped(App\Models\Order::first()));"Confirmed by raw.githubusercontent.com
Cause 2 of 3
A 'Name <email>' string was given to the Address constructor
1Check
new Address('Jane <jane@example.com>') validates the whole string as an address and fails. Only Address::create() parses the 'Name <email>' form.
grep -rn "new Address(" app/2Fix
Pass the address and the name as two arguments, or use Address::create() for the combined string.
use Symfony\Component\Mime\Address;
new Address('jane@example.com', 'Jane Doe');
Address::create('Jane Doe <jane@example.com>');3Verify
Send again; the exception no longer appears.
php artisan tinker --execute="echo Symfony\Component\Mime\Address::create('Jane Doe <jane@example.com>')->getAddress();"Confirmed by raw.githubusercontent.com
Cause 3 of 3
A non-ASCII address and an SMTP server that does not support it
1Check
Symfony's mailer docs say non-ASCII characters are allowed in the local part and the domain, but you will see an exception if the SMTP server does not support it, and the sender address may not use a UTF-8 local part.
php artisan tinker --execute="echo config('mail.from.address');"2Fix
Use an ASCII sender address, and an ASCII recipient address unless your SMTP provider supports internationalised addresses.
# .env
MAIL_FROM_ADDRESS=hello@example.com3Verify
Send a test message again.
php artisan tinker --execute="Mail::raw('test', fn(\$m) => \$m->to('test@example.com'));"Confirmed by symfony.com
How do I stop it coming back?
- Validate email fields with the 'email' rule when the form is saved, so bad values never reach the mailer.
- Skip or queue-fail cleanly for users without an address instead of letting the exception bubble.
- Keep MAIL_FROM_ADDRESS plain ASCII.
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
Laravel tries to send mail to mailpit:1025 instead of your real SMTP server
Symfony\Component\Mailer\Exception\TransportException
Laravel is still using the development mail host from the starter .env, mailpit on port 1025, which only exists inside Laravel Sail.
3 causes, each with a fixLaravel says the email was sent, but nothing arrives
Mail::to($user)->send() returns normally
Mail::send returns without an error when the message was accepted by the configured mailer, not when it was delivered.
3 causes, each with a fixLaravel mail fails with 'Unable to connect with STARTTLS' and SSL operation failed with code 1
stream_socket_enable_crypto(): Peer certificate verification failed
The mail server offered STARTTLS, but PHP could not verify the certificate it presented.
3 causes, each with a fixCodeIgniter email does not send and shows no error message
$email->printDebugger() prints an empty result
CodeIgniter signals a failed email only by send() returning false, with no exception.
4 causes, each with a fixPHP mail() returns true but the email never arrives
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing
mail() returning true only means the message was accepted for delivery, not that it arrived.
4 causes, each with a fixPHPMailer addCC() adds no CC recipient
The mail arrives for the To address but not for the CC address
addCC() returns false when it rejects the address, and PHPMailer then sends without that CC.
3 causes, each with a fix