Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mail::send() not working in Laravel 5

Tags:

I am continuously getting this error 'Class 'App\Http\Controllers\Mail' not found' error in my UserController.php

    public function store(CreateUserRequest $request)
{
    $result = DB::table('clients')->select('client_code','name','email')
                                  ->where('client_code','=',$request->code)
                                  ->where('email','=',$request->email)
                                  ->first();

    if($result){
        $tmp_pass = str_random(10);
        $user = User::create([
            'username'      => $result->name,
            'email'         => $request->email,
            'password'      => $tmp_pass,
            'tmp_pass'      => '',
            'active'        => 0,
            'client_code'   => $request->code
        ]);

        if($user){
            Mail::send('emails.verify',array('username' => $result->name, 'tmp_pass' => $tmp_pass), function($message) use ($user){
                $message->to($user->email, $user->username)
                    ->subject('Verify your Account');
            });
            return Redirect::to('/')
                ->with('message', 'Thanks for signing up! Please check your email.');
        }
        else{
            return Redirect::to('/')
                            ->with('message', 'Something went wrong');
        }
    }
    else{
        Session::flash('message', "Invalid code or email.");
        return redirect('/');
    }
}

Mail function used to work in Laravel 4 but I am getting errors in Laravel 5. Any help would be appreciated.