I am very new to this Laravel. I'm trying to send a respond email by reading the Email Address Inputted from the create.blade.php But it appears an error like this:
Symfony \\ Component \\ Debug \\ Exception \\ FatalThrowableError (E_RECOVERABLE_ERROR) Argument 2 passed to Illuminate\\Mail\\Mailer::send() must be of the type array, object given, called in /Users/steveruru/newsletter/newsletter/supticket/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 221
TicketController:
public function index(){
$inputs = Inputs::all();
return view('index', [
'inputs' => $inputs
]);
}
public function create(){
return view('create');
}
public function store(Request $request)
{
$inputs = new Inputs();
$inputs->inputName = $request->inputName;
$inputs->inputAddress = $request->inputAddress;
$inputs->inputBDO = Carbon::parse($request->inputBDO);
$inputs->inputEmail = $request->inputEmail;
$inputs->inputPhone = $request->inputPhone;
$inputs->inputJob = $request->inputJob;
$inputs->save();
Mail::send('mail', $inputs, function ($message) use($request) {
$message->from($request->inputName,$request->inputAdress);
$message->to($request->inputEmail)->subject('Alt Support');
});
return redirect ('home');
}
}
create.blade.php
<form action="{{ URL::to('/input') }}" method="POST">
{!! csrf_field() !!}
Name: <input type="text" name="inputName">
Address: <input type="text" name="inputAddress">
Birthday: <input type="date" name="inputBDO">
Email: <input type="text" name="inputEmail">
Phone: <input type="text" name="inputPhone">
Job: <input type="text" name="inputJob">
<br>
<input type="submit" value="Add Input">
</form>
Routes
Route::get('/', 'TicketController@index');
Route::get('/input/create', 'TicketController@create');
Route::post('/input', 'TicketController@store');
Mail::send('mail', $inputs->inputEmail, function ($message) use($request) {
$message->from($request->inputName,$request->inputAdress);
$message->to($request->inputEmail)->subject('Alt Support');
});
Mail send second parameter needs to be either an array of emails, or a single email as a string
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.