I am working on a University project and I want to send emails using MAIL_DRIVER=mail I had this working yesterday and now it seems to have stopped working? I have attached my code below.
Contact.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<style>
.invalid-feedback {
display: block;
}
</style>
<title> Contact </title>
</head>
<body>
<div class="container">
<h1> Feedback Form </h1>
<div class="row">
<div class="col-md-6">
@if (Session::has('flash_message'))
<div class="alert alert-success">{{ Session::get('flash_message') }}</div>
@endif
<form method="post" action="{{route('contact.store')}}">
{{ csrf_field() }}
<div class="form-group">
<label> Full Name: </label>
<input type="text" class="form-control" name="name">
@if ($errors->has('name'))
<small class="form-text invalid-feedback"> {{ $errors->first('name') }}</small>
@endif
</div>
<div class="form-group">
<label> Email: </label>
<input type="text" class="form-control" name="email">
@if ($errors->has('email'))
<small class="form-text invalid-feedback"> {{ $errors->first('email') }}</small>
@endif
</div>
<div class="form-group">
<label> Technical Ability: </label>
<textarea name="message" class="form-control"></textarea>
@if ($errors->has('message'))
<small class="form-text invalid-feedback"> {{ $errors->first('message') }}</small>
@endif
</div>
<button class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</body>
</html>
ContactMessageController
<?php
namespace App\Http\Controllers;
use Mail;
use Illuminate\Http\Request;
class ContactMessageController extends Controller
{
public function create(){
return view('contact');
}
public function store(Request $request)
{
$this->validate($request,[
'name' => 'required',
'email' => 'required|email',
'message' => 'required'
]);
Mail::send('emails.contact-message', [
'msg' => $request->message
], function ($mail) use($request) {
$mail->from($request->email, $request->name);
$mail->to('niamh3516@hotmail.co.uk')->subject('Contact message');
});
return redirect()->back()->with('flash_message', 'Thank you for your message');
}
}
My .env looks like this :
MAIL_DRIVER=mail
MAIL_HOST=smtp.live.com
MAIL_PORT=25
MAIL_USERNAME=myemail@hotmail.co.uk
MAIL_PASSWORD=password
I get a message to say "Thank you for your message" and it appears to work but I do not get an email.
Thanks in advance.