给定 [] 邮箱中的地址不符合 RFC 2822, 3.6.2.当电子邮件在变量中时 [英] Address in mailbox given [] does not comply with RFC 2822, 3.6.2. when email is in a variable

查看:36
本文介绍了给定 [] 邮箱中的地址不符合 RFC 2822, 3.6.2.当电子邮件在变量中时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正确的电子邮件地址.我已经回显了它,但是当我发送它时,我收到以下错误:

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.当电子邮件在变量中时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆