laravel 5.4: sending email from localhost not working

前端 未结 4 1355
失恋的感觉
失恋的感觉 2020-12-20 20:47

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         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-20 21:38

    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

提交回复
热议问题