[英]Why is my html e-mail blank in GMail? (Codeigniter)
我正在嘗試使用codeigniter發送HTML電子郵件,但是當我使用GMail檢查我的收件箱時,該消息是空白的。 它為什么這樣做?
我檢查了類似的問題,但似乎沒有提供有效的答案。
這是我的控制器:
<?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' => "\r\n"
);
$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();
}
}
我的觀點是:
<html>
<body>
<h2>Some text</h2>
</body>
</html>
我從“print_debugger()”中沒有收到任何錯誤,並且消息按預期顯示。
您需要將TRUE
作為第三個參數傳遞給視圖:
$message = $this->load->view("email/default_view", null , true);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.