我有一个正确的电子邮件地址.我已经回显了它,但是当我发送它时,我收到以下错误:
I have a correct email address. I have echoed it, but when I send it, I get the following error:
Address in mailbox given [] does not comply with RFC 2822, 3.6.2.
为什么?我使用 laravel (swift mailer) 发送电子邮件:
Why? I use laravel (swift mailer) to send email:
$email = email@address.com
然后当我发送它时,就会抛出错误.
and then when I send it, the error is thrown.
但如果我直接使用字符串,它会发送它.
But if I directly use the string, it sends it.
这里是块:
Mail::send('emails.activation', $data, function($message){
$message->to($email)->subject($subject);
});
->with('title', "Registered Successfully.");
你的email变量因为作用域是空的,你应该设置一个use子句比如:
Your email variable is empty because of the scope, you should set a use clause such as:
Mail::send('emails.activation', $data, function($message) use ($email, $subject) {
$message->to($email)->subject($subject);
});
这篇关于给定 [] 邮箱中的地址不符合 RFC 2822, 3.6.2.当电子邮件在变量中时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!