codeigniter发送电子邮件而不配置电子邮件库

I have strange issue and not sure what it cause this issue. Firstly i have below code in my controller,

    $this->load->library('email');
    $this->email->from('2@2.com', 'Test email');
    $this->email->to($this->session->userdata('user_email')); 

    $this->email->subject($subject);
    $this->email->message($message);    
    $this->email->send();
    $this->email->print_debugger();

My Email library is like below,

class CI_Email {

var $useragent      = "CodeIgniter";
var $mailpath       = "/usr/sbin/sendmail"; // Sendmail path
var $protocol       = "mail";   // mail/sendmail/smtp
var $smtp_host      = "";       // SMTP Server.  Example: mail.earthlink.net
var $smtp_user      = "";       // SMTP Username
var $smtp_pass      = "";       // SMTP Password
var $smtp_port      = "25";     // SMTP Port
var $smtp_timeout   = 5;        // SMTP Timeout in seconds
var $smtp_crypto    = "";       // SMTP Encryption. Can be null, tls or ssl.
var $wordwrap       = TRUE;     // TRUE/FALSE  Turns word-wrap on/off

I have two problem,

  1. I am not sure why it is sending email without specifying smtphost, user, pass, port etc in CI_Email class, when i click button in my view, controller runs and send email to session user email.

  2. Email can come to my company email, but it can not send to my gmail, live emails even i kept CC in controller, then i receive email in my company mailbox, i can see CC of my gmail address, but in Gmail box, there is no email.

Initially i did typed my gmail smtp settings in Email library variable, but for other testing i removed it. Then after even after there are no gmail SMTP setting in library i can see emails go out and that too my company email, not in Gmail or Live email,

Does we must configure something in CI_Email class library?

Any thoughts?

I found answer, issue was in below code

$protocol       = "mail";

This is default protocol which send email through PHP and email will go to in same domain only, not outside of domain, I used then SMTP protocol for gmail then it worked, With PHP 5.6 there is issue with SMTP, but with php 5.5 it worked!