Codeigniter电子邮件库在发送html邮件时出错

时间:2014-08-03 07:01:45

标签: php codeigniter html-email

您好我正在使用codeigniter电子邮件库发送邮件。它在默认配置(mailtype = text)中工作正常。但是当我将mailtype更改为'html'时,它会发送一封空白电子邮件。以下是我的代码。

public function sendmail($mail){
    $config = Array( 
        'useragent' => 'SPTechbook.com', 
        'mailtype' => 'html',
        'crlf'     => '\r\n',
        'newline'  => '\r\n',
        'charset' => 'iso-8859-1'
         );     
    $this->load->library('email',$config);


    $this->email->from('donot-reply@sptechbook.com', 'SPTechbook');

    $this->email->to($mail); 

    $this->email->subject('Email Verification');
    $message=$this->load->view('templates/email/email.php',TRUE);
    $this->email->message($message);

    $this->email->send();

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

}

以下是print_debugger()

的输出
Your message has been successfully sent using the following protocol: mail

User-Agent: SPTechbook.com
Date: Sun, 3 Aug 2014 06:21:14 +0000
From: "SPTechbook" <donot-reply@sptechbook.com>
Return-Path: <donot-reply@sptechbook.com>
Reply-To: "donot-reply@sptechbook.com" <donot-reply@sptechbook.com>
X-Sender: donot-reply@sptechbook.com
X-Mailer: SPTechbook.com
X-Priority: 3 (Normal)
Message-ID: <53ddd4daa9a57@sptechbook.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_53ddd4daa9aa1"


=?iso-8859-1?Q?Email_Verification?=
This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_53ddd4daa9aa1
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit




--B_ALT_53ddd4daa9aa1
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable



--B_ALT_53ddd4daa9aa1--

我也尝试过crlf ='\ n'和newline ='\ n'但没有成功,我收到一封空白的电子邮件。也尝试使用字符集UTF-8但没有成功。电子邮件模板也不是空白。这是一个完整的网页,有适当的身体。

1 个答案:

答案 0 :(得分:0)

您的数据在哪里?

$message=$this->load->view('templates/email/email.php', $your_data, TRUE);

见最后一段:Returning views as data