简体   繁体   English

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

[英]Codeigniter Email library gives error when sending html mail

Hi i am using codeigniter email library to send mail. 嗨,我正在使用codeigniter电子邮件库发送邮件。 It works fine in default config (mailtype=text). 在默认配置(mailtype = text)中,它可以正常工作。 But when i change mailtype to 'html' it sends a blank email. 但是,当我将邮件类型更改为“ html”时,它将发送空白电子邮件。 Below is my code. 下面是我的代码。

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();

}

Below is the output of 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--

also i have tried with crlf='\\n' and newline='\\n' but no success, I get a blank email. 我也尝试了crlf ='\\ n'和newline ='\\ n',但是没有成功,我收到了一封空白电子邮件。 Also tried with charset UTF-8 but no success. 也尝试使用字符集UTF-8,但没有成功。 The email template is not blank either. 电子邮件模板也不是空白。 It is a complete webpage with a proper body. 这是一个具有适当正文的完整网页。

Where is your data? 您的数据在哪里?

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

See last paragraph: Returning views as data . 请参阅最后一段: 将视图作为数据返回

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM