Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 5.2未发送的电子邮件_Laravel_Email_Registration - Fatal编程技术网

Laravel 5.2未发送的电子邮件

Laravel 5.2未发送的电子邮件,laravel,email,registration,Laravel,Email,Registration,在网站上注册后尝试发送激活邮件(使用身份验证控制器) 这是我的控制器的代码: protected function create(array $data) { $data['activation_code'] = str_random(20); return User::create([ 'firstname' => $data['firstname'], 'lastname' => $data['lastname'],

在网站上注册后尝试发送激活邮件(使用身份验证控制器)

这是我的控制器的代码:

protected function create(array $data)
{
    $data['activation_code'] = str_random(20);

    return User::create([
        'firstname' => $data['firstname'],
        'lastname' => $data['lastname'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
        'activation_code' => $data['activation_code'],
    ]);

    Mail::send('emails.register', $data, function($message) use ($data)
    {
        $message->from('info@foodtruckbestellen.be', "Foodtruckbestellen.be");
        $message->subject("Welkom bij foodtruckbestellen.be");
        $message->to($data['email']);
    });
}
<h1>Hi {{ $data['firstname'] }}</h1>
<p>
    Link = <a href="http://192.168.33.10/register/activate?code={{ $data['verification_code'] }}'">CLICK ME</a>
</p>
下面是我的电子邮件视图的代码:

protected function create(array $data)
{
    $data['activation_code'] = str_random(20);

    return User::create([
        'firstname' => $data['firstname'],
        'lastname' => $data['lastname'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
        'activation_code' => $data['activation_code'],
    ]);

    Mail::send('emails.register', $data, function($message) use ($data)
    {
        $message->from('info@foodtruckbestellen.be', "Foodtruckbestellen.be");
        $message->subject("Welkom bij foodtruckbestellen.be");
        $message->to($data['email']);
    });
}
<h1>Hi {{ $data['firstname'] }}</h1>
<p>
    Link = <a href="http://192.168.33.10/register/activate?code={{ $data['verification_code'] }}'">CLICK ME</a>
</p>

用户被保存在数据库中没有任何问题,但是我的电子邮件没有发送出去。我没有收到任何错误,因此我不确定发生了什么。

您需要设置.env文件。只需在mailtrap注册并将用户名和密码从mailtrap复制/粘贴到.env文件

编辑:


试试这个代码。我认为您必须使用
use
,并且
$data
必须在数组中。希望这有帮助。

您需要设置.env文件。只需在mailtrap注册并将用户名和密码从mailtrap复制/粘贴到.env文件

编辑:


试试这个代码。我认为您必须使用
use
,并且
$data
必须在数组中。希望这有帮助。

你能检查一下你系统的邮箱,看看有没有日志吗?@weigreen我只是在我的本地主机上你能检查一下你系统的邮箱,看看有没有日志吗?@weigreen我只是在我的本地主机上,我刚刚做了,但邮箱里似乎没有收到任何电子邮件。这有帮助吗@Nicolas Decroosnop,仍然没有收到任何东西我只是这样做了,但是mailtrap似乎没有收到收件箱中的任何电子邮件,这有帮助吗@Nicolas还是什么都没收到