codeigniter中的电子邮件发送错误

时间:2017-10-18 07:40:07

标签: php codeigniter email

我正在开发一个需要发送电子邮件的项目。我将它用作我的控制器

$from_email = $this->input->post('email'); 
$to_email = "info@test.com"; 
$name = $this->input->post('name'); 
$phno = $this->input->post('phno'); 
$from = $this->input->post('start');
$to = $this->input->post('end');
$message = $this->input->post('message');
    $bodyContent="<table>
    <tr><td>Name:</td><td>$name</td></tr>
    <tr><td>Phno:</td><td>$phno</td></tr>
    <tr><td>From Date:</td><td>$from</td><td>To Date:</td><td>$to</td></tr>
    <tr><td>Message:</td><td>$message</td></tr>
    </table>";
//Load email library 
    $this->load->library('email'); 
    $this->email->from($from_email, $name); 
    $this->email->to($to_email);
    $this->email->subject('Enquiry From Test TOURS'); 
    $this->email->message($bodyContent); 
//Send mail 
if($this->email->send()) {
    $this->session->set_flashdata("email_sent","Email sent successfully."); 
} else {
    $this->session->set_flashdata("email_sent","Error in sending Email."); 
}
redirect('test_view/index');

我正在收到邮件中的输出

<table>
    <tr><td>Name:</td><td>wer</td></tr>
    <tr><td>Phno:</td><td>wer</td></tr>
    <tr><td>From Date:</td><td>10/18/2017</td><td>To
    Date:</td><td>10/25/2017</td></tr>
    <tr><td>Message:</td><td>wer</td></tr>
</table>

我不知道为什么我会像这样在邮件中输出,请问任何人都可以解决这个错误。

2 个答案:

答案 0 :(得分:0)

您需要将类型设置为html:

  

$这 - &GT;的电子邮件 - &GT; set_mailtype( “HTML”);

答案 1 :(得分:0)

使用mailtype配置&#39; html&#39;在电子邮件配置文件

$config['mailtype'] = 'html';

来自user guide