HTML电子邮件不会发送codeigniter

时间:2016-04-07 11:11:57

标签: html codeigniter email smtp

这是我发送HTML电子邮件的代码,但它无法正常工作。只是原始的HTML代码显示在电子邮件中。

        $emailID = $this->input->post('email');
        $name = $this->input->post('name');

        $this->load->library('email');

        $config['protocol'] = 'smtp';
        $config['mailtype'] = 'html';
        $config['crlf'] = "\r\n";
        $config['wordwrap'] = TRUE;
        $config['newline'] = "\r\n";
        $config['validate'] = FALSE;

        $this->email->set_newline("\r\n");
        $this->email->from($emailID,$name);
        $this->email->to('vishvajitmahida009@gmail.com');
        $this->email->subject('Email Testing');
        $this->email->message('from clientside mail'); 
        $this->email->send();  

        $message = $this->load->view('emailfile/file','',TRUE);             
        $this->load->library('email', $config);
        $this->email->from($emailID,$name);
        $this->email->to($emailID,$name);
        $this->email->subject('Email Testing');
        $this->email->message($message);   
        $this->email->send();
        //echo $this->email->print_debugger();

1 个答案:

答案 0 :(得分:1)

添加$this->email->initialize($config);

$this->load->library('email');  
$config['protocol'] = 'smtp';
$config['mailtype'] = 'html';
$config['crlf'] = "\r\n";
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";
$config['validate'] = FALSE;
$this->email->initialize($config);