I am trying to send mail from my contact form. But I am getting error.
contact.blade.php is:
<form method="post" action="">
<table align="center" width="400">
<tr>
<td><strong>Full Name</strong></td>
<td><input type="text" name="name" required="required" /></td>
</tr>
<tr>
<td><strong>Contact No.</strong></td>
<td><input type="text" name="mobno" required="required" /></td>
</tr>
<tr>
<td><strong>Email ID</strong></td>
<td><input type="text" name="email" required="required" /></td>
</tr>
<tr>
<td><strong>Message</strong></td>
<td><textarea name="msg" cols="30" rows="3" required="required"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" /></td>
</tr>
</table>
</form>
web.php is:
Route::POST('send', 'ContactController@send');
ContactController.php is:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\officeholder;
use App\Mail\SendMail;
use Mail;
class ContactController extends Controller
{
public function send()
{
Mail::send(new sendMail());
}
}
I have created SendMail.php using php artisan make:mail SendMail by my cmd and then App\Mail\SendMail.php is created.
SendMail.php is:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Http\request;
class SendMail extends Mailable
{
use Queueable, SerializesModels;
public function __construct()
{
//
}
public function build(Request $request)
{
return $this->view('contact',['msg'=>$request->msg])->to('mymail@gmail.com');
}
}
But I got error after click button on form.
1/1) FatalErrorException Class 'App\Http\Controllers\sendMail' not found
in ContactController.php line 18
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire