为什么HTML电子邮件的一部分在电子邮件客户端中显示为文本? [英] Why is part of the HTML email appearing as text in email client?

查看:157
本文介绍了为什么HTML电子邮件的一部分在电子邮件客户端中显示为文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Codeigniter的电子邮件类发送HTML电子邮件。这是我做的:

I am trying to send HTML emails with Codeigniter's email class. This is how I am doing it:

    $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => 'a@a.com',
        'smtp_pass' => 'password',
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
    );

    $this->load->library('email', $config);
    $this->email->from('b@b.com', 'Me');
    $this->email->to($email); 
    $this->email->subject($subject);
    $this->email->message($html);
    $this->email->set_newline("\r\n"); 

    if($this->email->send()){
        return true;   
    }else{    
        return false;
    }

但是,当我在Gmail或Outlook中查看电子邮件时, HTML在电子邮件顶部显示为文本,电子邮件的其余部分正常显示。

However, when I view the email in Gmail or outlook, I see bunch of HTML appearing as text at the top of the email and the the rest of the email is displayed normally.

这里 是我发送的HTML,它是我发现要测试的模板。第1到19行显示为正常文字,未呈现。

Here is the HTML I am sending, its a template that I found to test with. Lines 1 to 19 appear as normal text and is not rendered.

This is how the email looks.

为什么会是这种情况?

推荐答案

作为我们在问题评论中的对话的总结,问题似乎是 $ html 变量。该变量包含实体编码的HTML。通过 html_entity_decode 运行它解决了这个问题。

As a summary of our conversation in the question's comments, the problem appears to be the content of the $html variable. The variable contains entity encoded HTML. Running it through html_entity_decode solved the problem.

这篇关于为什么HTML电子邮件的一部分在电子邮件客户端中显示为文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆