Codeigniter - 电子邮件类 - HTML电子邮件加载视图

时间:2014-01-20 08:28:06

标签: php html codeigniter email

我需要发送一封HTML电子邮件,但在我添加的消息中,从视图中加载HTML文件,但是当我发送电子邮件并接收它时,但是电子邮件是空白的,请不要从视图文件中获取文本。

public function sendUserMail($mail) {
            $data=true;
            $lang = $this->input->post("lang");
            $this->email->from('noreply@giftotravel.pk', 'Halalat');
            $this->email->to($mail); 
            $this->email->subject('Halalat Newsletter Subscription');
            $this->email->set_mailtype("html");
             if ($lang == "en") {
            $this->email->message = $this->load->view('email', $data, TRUE);
            }
            else  
            {
            $this->email->message('<img src="http://fahad.myradio.pk/assests/images/ar/bg_ar3.jpg" />');   
            }
            //$this->email->attach('/home/content/f/a/h/fahadghafoor/html/fahad/assests/images/en/bg_en2.jpg');//attachement testing done
            $this->email->send();
            echo $this->email->print_debugger();
        }

2 个答案:

答案 0 :(得分:3)

设置电子邮件应该是这样的:

$this->email->message($this->load->view('email', $data, TRUE));

答案 1 :(得分:2)

试试这个:

$msg = $this->load->view('email', $data , true);
$this->email->message($msg);