我有一個codeigniter項目,通過它我希望發送電子郵件給用戶。我希望發送具有HTML代碼效果的模板,但在電子郵件內我要越過html代碼,而不是視圖。誰能告訴怎麼做無法通過電子郵件codeigniter發送視圖/模板
代碼,我現在用的就是
查看
<?php echo form_open('home/forgot_pass'); ?>
<div class="form-group">
<?php
$data = array(
'type'=>'text',
'class' => "form-control",
'name'=>'email',
'autocomplete'=>'off',
'placeholder'=>'Email'
);
?>
<?php echo form_input($data); ?>
</div>
<div class="form-group">
<?php
$data = array(
'type'=>'submit',
'class'=>'btn btn-success btn-block',
'name'=>'submit',
'content'=>'Login'
);
echo form_button($data);
?>
</div>
<?php echo form_close(); ?>
控制器
public function forgot_pass()
{
$this->user_model->forgot_pass();
}
型號
public function forgot_pass()
{
$email = $this->input->post('email');
$this->db->where('email',$email);
$query = $this->db->get('users');
$result = $query->row();
if($result)
{
$password = $result->password;
$from_email = "[email protected]";
$this->load->library('email');
$this->email->from($from_email, 'ABC');
$data = array(
'password'=> $password
);
$this->email->to($email);
$this->email->subject('Forgot Password');
$body = $this->load->view('users/forgot_password_email',$data,TRUE);
$this->email->message($body);
$this->email->send();
}
}
誰能告訴如何發送模板通過笨
電子郵件forgot_password_email視圖
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="padding: 8px;">
<span style="color:white;text-align:center;margin-left: 45%;font-size: 20px;font-weight: 600;">LITEHIRES</span>
</nav>
<div class="container" style="margin-left: 25%; margin-top: 4%;">
<p style="font-weight: 600; font-size: 18px;">Hi Samya</p>
<p> You have recently requested for a password on your litehires account. Please use the following password for your account</p>
<p style=" margin-left: 25%; color: #3498db; font-size: 16px; "><?php echo $password; ?></p>
<p>Thanks</p>
<p style=" margin-top: -10px; ">Litehires Team</p>
</div>
</body>
</html>
它的工作,但它顯示的HTML代碼,而不是頁面 – user3732711
它把您的頁面代碼作爲一個字符串.. –
所以如何顯示電子郵件在適當的格式 – user3732711