简体   繁体   English

Codeigniter不使用SMTP设置发送电子邮件

[英]Codeigniter not sending email with smtp settings

I have the email.php in config folder: 我在config文件夹中有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
);

and this function in helper 而这个功能在助手中

    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;
    }

The problem is that the CI is sending the email even if I type wrong credentials. 问题是即使我输入了错误的凭据,CI也会发送电子邮件。 Why is happening this? 为什么会这样呢? I know email.php from config folder is loaded automatically. 我知道config文件夹中的email.php会自动加载。

There is nothing you have to do in E-mail library, Use this 在电子邮件库中您无需执行任何操作,请使用此功能

$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"
}

Email Class 电子邮件类别

解决了

'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
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM