【发布时间】:2015-05-28 07:30:33
【问题描述】:
我在发送 html 电子邮件 codeigniter 时遇到问题。对于文本来说还可以,但在使用 html 进行样式设置时,它总是显示代码。搜索了很多并将该电子邮件配置数组项更改为许多。但结果是相同的 html 代码。请帮帮我..
这是我的控制器功能
public function contact_process()
{
$name=$this->input->post('txt_name');
$phone=$this->input->post('txt_phone');
$from_email=$this->input->post('txt_email');
$message=$this->input->post('txt_message');
$config = Array(
'protocol' => 'sendmail',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'my_email_id@gmail.com',
'smtp_pass' => 'my_password',
'mailtype' => 'html',
'charset' => 'utf-8',
'priority' => '1',
'wordwrap' => 'true'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$to_email = 'to_email_id@gmail.com';
$subject = "Product Request Mail";
$body = "<html>
<head><title>Best Price</title></head>
<body>
<div style='max-width: 800px; margin: 0; padding: 30px 0;'>
<table width='80%' border='1' cellpadding='0' cellspacing='0'>
<tr>
<td width='5%'></td>
<td align='left' width='95%' style='font: 13px/18px Arial, Helvetica, sans-serif;'>
<h2 style='font: normal 20px/23px Arial, Helvetica, sans-serif; margin: 0; padding: 0 0 18px; color: black;'>Contact Mail</h2>
<br />
<big style='font: 16px/18px Arial, Helvetica, sans-serif;'> Name : '.$name.'</big><br />
<big style='font: 16px/18px Arial, Helvetica, sans-serif;'> Phone : '.$phone.'</big><br />
<big style='font: 16px/18px Arial, Helvetica, sans-serif;'> Email : '.$from_email.'</big><br />
<big style='font: 16px/18px Arial, Helvetica, sans-serif;'> Message : '.$message.'</big><br />
</td>
</tr>
</table>
</div>
</body>
</html>";
//send mail
$this->email->from($from_email, $name);
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($body);
//echo $this->email->send();
//echo $this->email->print_debugger();
if ($this->email->send())
{
redirect('user/bestprice/contact/', 'refresh');
}
else
{
redirect('user/bestprice/contact/', 'refresh');
}
}
【问题讨论】:
标签: html codeigniter email