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


How can i send email with html template?

我在codeigniter中发送了一个模板html,实际上我的电子邮件工作正常。

我的问题是如何将 html 模板发送到电子邮件正文。我收到了带有 html 代码的电子邮件。

这是我的控制器-

$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("'r'n");
// 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);

请尝试此希望这有帮助

试试这个$this->email->set_mailtype("html");