电子邮件无法使用ci 3.0应用程序

I was using ci 2.2 with smtp email, and as usual it was working and is currently working fine, but when I upgraded my app to ci 3.0, it is giving me error:

Failed to authenticate password. Error: 535 Authentication Failed Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

Now here is the code I'm using ci app 2.2 email code':

function sendEmail($to,$subject,$body,$from = "Do not reply")
{
    $CI =& get_instance();
    $CI->load->library('email');
    $config['protocol']     = 'smtp';
    $config['smtp_host']    = 'ssl://smtp.myserviceprovider.com';
    $config['smtp_port']    = '465';
    $config['smtp_timeout'] = '7';
    $config['smtp_user']    = 'email@myemail.com';
    $config['smtp_pass']    = 'email_password';
    $config['charset']      = 'utf-8';
    $config['newline']      = "
";
    $config['mailtype']     = 'html'; // or html
    $config['validation']   = TRUE; // bool whether to validate email or not
    $CI->email->initialize($config);
    $CI->email->from('emaily@myemail.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();
    }
}

//I'm using a custom helper to send email, this is working code

//This code is not working with ci 3.0

$config['protocol']     = 'smtp';
$config['smtp_host']    = 'ssl://smtp.myserviceprovider.com';
$config['smtp_port']    = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user']    = 'email@myemail.com';
$config['smtp_pass']    = 'email_password';
$config['charset']      = 'utf-8';
$config['newline']      = "
";
$config['mailtype']     = 'html'; // or html
$config['validation']   = TRUE; // bool whether to validate email or not
$this->email->initialize($config);
$this->email->from('email@myemail.com','FirstName LastName');
$this->email->to('to@too.com'); 
$this->email->subject(rand(1000,9999));
$this->email->message('body of email');
if($this->email->send())
{
    echo $this->email->print_debugger();
}
else
{
    echo $this->email->print_debugger();
}

This code is not working. I don't know why, using ci 3.0. Is there something I'm missing, because if the code is working with ci 2.2 without problem, it should be working with other part too.