laravel 8 中的电子邮件发送问题 'Swift_RfcComplianceException'
Email Sending issue 'Swift_RfcComplianceException' in laravel 8
我在发送邮件时遇到 Swift_RfcComplianceException 错误
我的代码是这样的
Mail::send([],[], function ($message) use ($fromName,$fromEmail,$subject,$data,$toEmilId){
$message->to($toEmilId)
->from($fromEmail,$fromName)
->subject($subject)
->setBody($data,'text/html');
});
得到的错误是
"message": "Address in mailbox given [] does not comply with RFC 2822, 3.6.2.",
"exception": "Swift_RfcComplianceException",
"file": "E:\NaveenNayak\wamp-projects\subscriptionapi\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\Headers\MailboxHeader.php",
"line": 355,
我已经清除了
php artisan cache:clear
、php artisan config:clear
和 php artisan config:cache
命令仍然出现相同的错误。
请帮我解决这个错误
看起来传递的变量 $fromEmail
、$toEmilId
、$fromName
是空的。
还要确保 trim $fromEmail
,$toEmilId
。即使您的电子邮件包含 space 开头或结尾,您也会收到错误消息。
例如我在 $fromEmail
中给出 space 然后我得到以下错误
$fromEmail=" ****@gmail.com";
Swift_RfcComplianceException Address in mailbox given [
****@gmail.com] does not comply with RFC 2822, 3.6.2.
如果您的发件人电子邮件或收件人电子邮件为空,则会出现以下错误
Swift_RfcComplianceException Address in mailbox given [] does not
comply with RFC 2822, 3.6.2.
此外,如果您的电子邮件地址无效,则会出现以下错误
$toaddress="johnlobo" so this invalid email address then error
Swift_RfcComplianceException Address in mailbox given [johnlobo]
does not comply with RFC 2822, 3.6.2.
我在发送邮件时遇到 Swift_RfcComplianceException 错误
我的代码是这样的
Mail::send([],[], function ($message) use ($fromName,$fromEmail,$subject,$data,$toEmilId){
$message->to($toEmilId)
->from($fromEmail,$fromName)
->subject($subject)
->setBody($data,'text/html');
});
得到的错误是
"message": "Address in mailbox given [] does not comply with RFC 2822, 3.6.2.",
"exception": "Swift_RfcComplianceException",
"file": "E:\NaveenNayak\wamp-projects\subscriptionapi\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\Headers\MailboxHeader.php",
"line": 355,
我已经清除了
php artisan cache:clear
、php artisan config:clear
和 php artisan config:cache
命令仍然出现相同的错误。
请帮我解决这个错误
看起来传递的变量 $fromEmail
、$toEmilId
、$fromName
是空的。
还要确保 trim $fromEmail
,$toEmilId
。即使您的电子邮件包含 space 开头或结尾,您也会收到错误消息。
例如我在 $fromEmail
中给出 space 然后我得到以下错误
$fromEmail=" ****@gmail.com";
Swift_RfcComplianceException Address in mailbox given [ ****@gmail.com] does not comply with RFC 2822, 3.6.2.
如果您的发件人电子邮件或收件人电子邮件为空,则会出现以下错误
Swift_RfcComplianceException Address in mailbox given [] does not comply with RFC 2822, 3.6.2.
此外,如果您的电子邮件地址无效,则会出现以下错误
$toaddress="johnlobo" so this invalid email address then error
Swift_RfcComplianceException Address in mailbox given [johnlobo] does not comply with RFC 2822, 3.6.2.