Friday, March 10, 2017

Laravel send mail and pass User email

I would like to send a register confirmation mail to my user. Everything works but how can I fill in the mail address dynamic from my user? something like this does not work: $message->to($user->email);

$user = new User();
        $user->email = $email;
        $user->name = $name;
        $user->password =$password;

        $user->save();

        $name = $user->name;
        $email = $user->email;

        Mail::send('email.registerMail', ['name'=>$name, 'email'=> $email], function ($message) {
            $message->from('info@abc.de', 'abc');

            $message->to($user->email);
        });

        return redirect()->route('success');

    }



via Fabian Tschullik

Advertisement