如何使用html模板发送电子邮件?

I am sending a template html in codeigniter and in fact my email is working perfectly fine.

My problem is how i send a template of html to the email body. I got email with html code.

Here is my controller-

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'testemail@gmail.com',
    'smtp_pass' => '**********',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("
");

// Set to, from, message, etc.
        $this->email->from('mygmail@gmail.com', 'myname');
        $this->email->to('Secur@gmail.com'); 

        $this->email->subject('Email Test');
        $this->email->message('<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<table border="1">
<tr>
<td>name</td>
<td>age</td>
</tr>
<tr>
<td>User1<td>
<td>20<td>
</tr>

</body>
</html>
');  

$result = $this->email->send(); 
$body='<!DOCTYPE html>    
<html>
<head>
<title></title>
</head>
<body>
<table border="1">
<tr>
<td>name</td>
<td>age</td>
</tr>
<tr>
<td>User1<td>
<td>20<td>
</tr>
</body>';

$this->email->message($body);

Please try this hope this helps

Try this $this->email->set_mailtype("html");