drl6054 2013-02-01 18:52 采纳率: 0%
浏览 22
已采纳

为什么我的HTML电子邮件在GMail中是空白的? (笨)

I'm trying to send a HTML e-mail using codeigniter but when I check my inbox using GMail the message is blank. Why is it doing this?

I have checked similar questions but none seem to provide an answer that worked.

This is my controller:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Email extends CI_Controller {



    public function index()
    {


        $message = $this->load->view("email/default_view",True);

        $email_config = Array(
            'protocol'  => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => '465',
            'smtp_user' => '****************',
            'smtp_pass' => '****************',
            'mailtype'  => 'html',
            'starttls'  => true,
            'newline'   => "
"
        );

        $this->load->library("email",$email_config);

        $this->email->from('*******', '*********');
        $this->email->to('********'); 

        $this->email->subject("Re: Contact");
        $this->email->message($message);    

        $this->email->send();

        echo $this->email->print_debugger();

    }

}

And my view:

<html>
  <body>
    <h2>Some text</h2>
</body>
</html>

I get no errors from "print_debugger()" and the message appears as expected.

  • 写回答

1条回答 默认 最新

  • drtzb06222 2013-02-01 18:54
    关注

    You need to pass TRUE as the third parameter to the view:

    $message = $this->load->view("email/default_view", null , true);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 表达式必须是可修改的左值
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题