Estoy intentando implementar un formulario de contacto en Laravel 5.6, tengo el siguiente formulario dentro de la carpeta pages:
<div class="row">
<div class="col-md-12">
<h1>Contact Me</h1>
<hr>
<form method="POST">
{{ csrf_field() }}
<div class="form-group">
<label name="email">Email:</label>
<input id="email" name="email" class="form-control">
</div>
<div class="form-group">
<label name="subject">Subject:</label>
<input id="subject" name="subject" class="form-control">
</div>
<div class="form-group">
<label name="message">Message:</label>
<textarea id="message" name="message" class="form-control">Type your message here...</textarea>
</div>
<input type="submit" value="Send Message" class="btn btn-success">
</form>
</div>
</div>
Controlador:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Post;
use Mail;
class PagesController extends Controller {
public function getContact() {
return view('pages.contact');
}
public function postContact(Request $request) {
$this->validate($request, [
'email' => 'required|email',
'subject' => 'min:3',
'message' => 'min:10']);
$data = array(
'email' => $request->email,
'subject' => $request->subject,
'bodyMessage' => $request->message
);
Mail::send('emails.contact', $data, function($message) use ($data){
$message->from($data['email']);
$message->to('
[email protected]');
$message->subject($data['subject']);
});
Session::flash('success', 'Your Email was Sent!');
return redirect('/');
}
}
Ruta:
Route::get('/contact', 'PagesController@getContact');
Route::post('/contact', 'PagesController@postContact');
Vista dentro de la carpeta emails:
<h3>You Have a New Contact Via the Contact Form</h3>
<div>
{{ $bodyMessage }}
</div>
<p>Sent via {{ $email }}</p>
Los archivos de configuración .env y config/email los tengo bien configurados, pero
No funciona, queda en la pagina de contacto sin direccionar,enviar mail, ni nada.
Agradezco quien me eche una mano.