Codeigniter未发送带有smtp设置的电子邮件


Codeigniter not sending email with smtp settings

我有配置文件夹中的email.php:

$config = Array(
    'protocol' => 'tls',
    'smtp_host' => 'mail.lifepro.ro',
    'smtp_port' => 465,
    'smtp_user' => 'office@lifepro.ro',
    'smtp_pass' => 'xxxxxxxxxxxx',
    'mailtype' => 'html',
    'charset' => 'utf-8',
    'wordwrap' => TRUE
);

以及辅助中的此功能

    function email_send($to, $subject, $body) {
        $ci = get_instance();
        $ci->email->from('office@lifepro.ro', 'Office LifePro');
        $ci->email->to($to);
        $ci->email->cc('office@lifepro.ro');
        $ci->email->subject($subject);
        $ci->email->message($body);
        if($ci->email->send())
            return true;
    }

问题是,即使我键入了错误的凭据,CI也在发送电子邮件。为什么会发生这种情况?我知道config文件夹中的email.php是自动加载的。

在电子邮件库中无需执行任何操作,使用此

$this->load->library('email'); //load library 
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');  
if(!$this->email->send())
{
    echo $this->email->print_debugger();
}
else
{
    echo "Sent"
}

电子邮件类

已解决

'protocol' => 'smtp'
$config = Array(
    'protocol' => 'smtp',
    'smtp_crypto' => 'tls', //         <--- notice
    'smtp_host' => 'mail.lifepro.ro',
    'smtp_port' => 465, //             <--- or 587
    'smtp_user' => 'office@lifepro.ro',
    'smtp_pass' => 'xxxxxxxxxxxx',
    'mailtype' => 'html',
    'charset' => 'utf-8',
    'wordwrap' => TRUE
);