I have a problem with send email with Laravel, it's my method:
public function store(CreateUserRequest $request){
$name = Input::get('name');
$imie = Input::get('imie');
$nazwisko = Input::get('nazwisko');
$email = array('email' => Input::get('email'));
$password = Input::get('password');
Mail::send(['name' => $name], function ($message) use ($name, $imie, $nazwisko, $email, $password) {
$message->from('[email protected]', 'System Magazyn');
$message->attach('Your temporary password: '.['password' => $password]);
$message->to(['email'=>$email])->subject('Rejestracja Magazyn');
});
User::create($request->all());
Session::flash('addUserOK', 'Użytkownik dodany poprawnie.');
return redirect('user');
}
This method saved to database new user. I want send email to new user with information on the correct registration and information with temporary password. I did as it is written in the documentation https://laravel.com/docs/5.2/mail#sending-mail and as it is in this topic: Laravel 4 from contact form to admin email, but still Laravel returned error:
FatalThrowableError in Mailer.php line 149: Type error: Argument 2 passed to Illuminate\Mail\Mailer::send() must be of the type array, object given, called in C:\xampp\htdocs\kurwa_magazyn\magazyn_michal\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 219
EDIT:
This is form to register new user:
{!! Form::open(['route' => 'user.store', 'method' => 'post', 'class' => 'form-horizontal']) !!}
{!! Form::text('name', null, ['class' => 'form-control', 'placeholder' => 'Nazwa użytkownika...']) !!}<br />
{!! Form::text('imie', null, ['class' => 'form-control', 'placeholder' => 'Imię...']) !!}<br />
{!! Form::text('nazwisko', null, ['class' => 'form-control', 'placeholder' => 'Nazwwisko...']) !!}<br />
{!! Form::email('email', null, ['class' => 'form-control', 'placeholder' => 'Adres e-mail...']) !!}<br />
{!! Form::text('password', uniqid(), array('class' => 'form-control', 'placeholder' => 'Podaj hasło...')) !!}<br />
{!! Form::select('permissions', array('0' => 'Pracownik fizyczny', '2' => 'Magazynier', '3' => 'Demo użytkownik', '1' => 'Administrator'), NULL, ['class' => 'form-control']) !!}<br />
{!! Form::hidden('remember_token', bcrypt(uniqid(rand(0,9)))) !!}
{!! Form::submit('Dodaj', ['class' => 'btn btn-default']); !!}
{!! Form::close() !!}