SMTP not working in CI 3.0 while same code is work

2019-06-02 22:08发布

This is a big issue i'm struggling with, the thing is our application needs to send email, now we are relying on smtp, until 2.*(latest) email worked fine, but as soon as we ported app in ci 3.0 everything worked by smtp, here is error we are getting on ci 3.0 sample email

A PHP Error was encountered

Severity: Warning

Message: fwrite(): SSL operation failed with code 1. OpenSSL Error messages: error:140D00CF:SSL routines:SSL_write:protocol is shutdown

Filename: libraries/Email.php

Line Number: 2131

Backtrace: has nothing, it is shown blank, used bold text to specify that

here is the issue i found on github Error trying to send a mail

i wonder if anyone is facing this issue, would appreciate help on this one

source code

function sendEmail($to,$subject,$body,$from = "My Company Name")
    {
        $CI =& get_instance();
        $CI->load->library('email');
        $config['protocol']     = 'smtp';
        $config['smtp_host']    = 'ssl://smtp.zoho.com';
        $config['smtp_port']    = '465';
        $config['smtp_timeout'] = '7';
        $config['smtp_user']    = 'no-reply@my_domain.com';
        $config['smtp_pass']    = 'secret_password';
        $config['charset']      = 'utf-8';
        $config['newline']      = "\r\n";
        $config['mailtype']     = 'html'; // or html
        $config['validation']   = TRUE; // bool whether to validate email or not
        $CI->email->initialize($config);
        $CI->email->from('no-reply@my_domain.com',$from);
        $CI->email->to($to); 
        $CI->email->subject($subject);
        $CI->email->message($body);
        if($CI->email->send())
        {
            //return true;
            echo $CI->email->print_debugger();
        }
        else
        {
            //return false;
            echo $CI->email->print_debugger();
        }
    }

0条回答
登录 后发表回答