用CI发送邮件

<?php
class Email extends CI_Controller
{
    function index()
    {
        // 配置信息
        $config = array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => 465,
            'smtp_user' => 'kinstudy14@gmail.com',
            'smtp_pass' => 'gzx1991@'
        );
        
        // 载入类库
        $this->load->library('email', $config);
        //$this->email->set_newline("\r\n");
        
        $this->email->from('kinstudy14@gmail.com', 'Kinslayer');
        $this->email->to('kinstudy14@gmail.com');
        $this->email->subject('测试');
        $this->email->message('成功了');
        
        if($this->email->send())
        {
            echo '邮件已发送';
        }
        else
        {
            show_error($this->email->print_debugger());
        }
    }
}

 

posted @ 2013-07-17 13:55  兽人从不挑食  阅读(198)  评论(0编辑  收藏  举报