I want to sent emails from my localhost with laravel 5.4. It is showing me the following error: screenshot of the error
This is my .env file
MAIL_DRI
I would suggest using the log driver for mail or setting up a mailgun free account but if you really wanna test this from your local dev machine then this answer might help:
This is a generic windows error when trying to send a mail.
Try uncommenting extension=php_openssl.dll
in php.ini
Route::get('sendemail', function () {
$data = array(
'name' => "Learning Laravel",
);
Mail::send('welcome', $data, function ($message) {
$message->from('ashokchavda193@gmail.com', 'Learning Laravel');
$message->to('ashokchavda193@gmail.com')->subject('Learning Laravel test email');
});
return "Your email has been sent successfully";
});
I had this issue too, this is how i fixed it. Though it is not advisable to change vendor files but this fix worked and it enable me to send mail from my localhost.
C:\xampp\htdocs\mylaravel\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
private function _establishSocketConnection(){
....
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
$streamContext = stream_context_create($options);
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
.... }
It's like the ssl keeps preventing the mail from been sent. I hope this helps