Skip to content

Email Notification Customizing The Recipient Bug in Laravel9 #40895

Closed
@karimnaimy

Description

@karimnaimy
  • Laravel Version: 9.0
  • PHP Version: 8.1
  • Database Driver & Version: MySQL

Description:

When the email address and name are returned from routeNotificationForMail in a modal, the RfcComplianceException is thrown.

public function routeNotificationForMail($notification)  
{  
        \Log::debug([$this->email => $this->name]);  
        return [$this->email => $this->name];
}

image

Log

[2022-02-09 16:48:36] local.DEBUG: array (
  '[email protected]' => 'karim',
)  
[2022-02-09 16:48:36] local.DEBUG: array (
  '[email protected]' => 'karim',
)  
[2022-02-09 16:48:36] local.ERROR: Email "karim" does not comply with addr-spec of RFC 2822. {"exception":"[object] (Symfony\\Component\\Mime\\Exception\\RfcComplianceException(code: 0): Email \"karim\" does not comply with addr-spec of RFC 2822. at /home/karim/www/example-app/vendor/symfony/mime/Address.php:54)
[stacktrace]
#0 /home/karim/www/example-app/vendor/symfony/mime/Address.php(96): Symfony\\Component\\Mime\\Address->__construct()
#1 /home/karim/www/example-app/vendor/symfony/mime/Address.php(115): Symfony\\Component\\Mime\\Address::create()
#2 /home/karim/www/example-app/vendor/symfony/mime/Email.php(528): Symfony\\Component\\Mime\\Address::createArray()
#3 /home/karim/www/example-app/vendor/symfony/mime/Email.php(169): Symfony\\Component\\Mime\\Email->setListAddressHeaderBody()
#4 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Mail/Message.php(211): Symfony\\Component\\Mime\\Email->to()
#5 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Mail/Message.php(105): Illuminate\\Mail\\Message->addAddresses()
#6 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(163): Illuminate\\Mail\\Message->to()
#7 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(135): Illuminate\\Notifications\\Channels\\MailChannel->addressMessage()
#8 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(80): Illuminate\\Notifications\\Channels\\MailChannel->buildMessage()
#9 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(267): Illuminate\\Notifications\\Channels\\MailChannel->Illuminate\\Notifications\\Channels\\{closure}()
#10 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(65): Illuminate\\Mail\\Mailer->send()
#11 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(148): Illuminate\\Notifications\\Channels\\MailChannel->send()
#12 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(106): Illuminate\\Notifications\\NotificationSender->sendToNotifiable()
#13 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\\Notifications\\NotificationSender->Illuminate\\Notifications\\{closure}()
#14 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(109): Illuminate\\Notifications\\NotificationSender->withLocale()
#15 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(79): Illuminate\\Notifications\\NotificationSender->sendNow()
#16 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(39): Illuminate\\Notifications\\NotificationSender->send()
#17 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Notifications/RoutesNotifications.php(18): Illuminate\\Notifications\\ChannelManager->send()
#18 /home/karim/www/example-app/vendor/laravel/framework/src/Illuminate/Auth/Passwords/CanResetPassword.php(27): App\\Models\\User->notify()
......
#70 {main}
"} 

Steps To Reproduce:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions