使用html和css使用CodeIgniter格式化电子邮件

使用html和css使用CodeIgniter格式化电子邮件,html,email,codeigniter,Html,Email,Codeigniter,我想通过电子邮件发送一个带有Codeigniter的简单视图,这样电子邮件对用户来说就好看了。我该怎么做?这是迄今为止我在控制器中的代码 public function test_email() { $message = $this->load->view('application/recommendation_email', '', TRUE); $this->load->library('email');

我想通过电子邮件发送一个带有Codeigniter的简单视图,这样电子邮件对用户来说就好看了。我该怎么做?这是迄今为止我在控制器中的代码

public function test_email()
        {
            $message = $this->load->view('application/recommendation_email', '', TRUE);
            $this->load->library('email');          
            $this->email->from('xxxxxxx@gmail.com', 'something');
            $this->email->to('xxxxxxx@gmail.com'); 
            $this->email->subject('Letter of Recommendation Request');
            $this->email->message($message);
            $this->email->send();
        }
目前它只是发送html代码给我。但我希望它像在浏览器中一样。这是我的html+css

    <html>

    <body>
        <p>Dear Joe<?php //echo $name ?>,
        </p>

        <p>SOME TEXT
        </p>

        <a href="a reference">a reference
        </a><br><br><br>

        <p>Thanks,<br><br>
            The Team
        </p>
    </body>
</html>


<style type='text/css'>

body{
    font-family: "Lucida Grande";
    background-color: #fdfdfd;
}
a {
  color: #008ee8;
  text-decoration: none;
  outline: none;
}
a:hover {
  color: #ec8526;
  text-decoration: none;
}


</style>
您需要将mailtype配置项设置为html。默认设置为文本:

您还可以通过如下数组设置电子邮件配置项:

$config['mailtype'] = 'html';
// ...other config items as necessary

$this->email->initialize($config);
还有:

如果您发送HTML电子邮件,则必须将其作为完整的网页发送。确保没有任何相对链接或相对图像路径,否则它们将无法工作


当我将mailtype设置为html时。。。它给我白色的屏幕。。?我有一个错误。。。我知道这是邮件类型。。。。无法更改邮件类型我有完全相同的问题@Kebyangbla我不知道是什么问题
$config['mailtype'] = 'html';
// ...other config items as necessary

$this->email->initialize($config);