开发者

Sending an html email with phpmailer and codeigniter

I am sending emails with phpmailer package and using the package with codeigniter framework. I have made a helper function out of the phpmailer package which takes arguments as sender's address, recipient's address, subject and message body. Everything goes fine and the message is delivered to the inbox.

My problem is I have a large body which can be a seperate html file. For this I have creat开发者_运维知识库ed a view and I am trying to send the argument $this->load->view('viewname'); through the helper function in my controller. But instead of displaying the body in mail I get the file displayed on my final view page and the mail body goes blank. Any idea how I can achieve


Using $this->load->view('viewname'); without any additional parameters will output the view. What you need is to set the third parameter to TRUE as suggested in the Returning views as data of the CodeIgniter User Guide's View documentation.

Example:

$string = $this->load->view('viewname', '', true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜