Virif

Laravel sending email from localhost not working

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.

  1. Locate StreamBuffer in your vendor folder. It should be in this location

C:\xampp\htdocs\mylaravel\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport

  1. Open the file StreamBuffer.php
  2. Find this method _establishSocketConnection
  3. Add this as shown below

$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