簡體   English   中英

在Codeigniter中發送HTML電子郵件

[英]Sending html email in Codeigniter

我在codeigniter中發送模板html,實際上我的電子郵件工作得非常好。

我的問題是如何將html模板發送到電子郵件。 由於傳遞給變量,我收到錯誤。

public function send_email_accountability($C11, $C4, $C8,$C12)
{
    date_default_timezone_set('Asia/Manila');
    $message = $this->load->view('sample_html',$data,TRUE); 
    $this->load->library('email');
    $this->email->set_mailtype("html");
    $this->email->from('noreply@email.com', 'EMAIL');
    $this->email->to($C11); 
    $this->email->subject('Accountability for'. $C12);
    $this->email->message($message);
}

我收到的電子郵件但電子郵件內部是php錯誤,因為$data無法傳遞給。 我查看了其他stackoverflow問題,但這對我的問題沒有幫助。

public function send_email_accountability($C11, $C4, $C8,$C12)
{
    date_default_timezone_set('Asia/Manila');
    $this->load->library('email');
    $data['title']='HELLO WORLD';
    $this->email->from('noreply@email.com', 'EMAIL');
    $this->email->to($C11); 
    $this->email->subject('Accountability for'. $C12);
    $this->email->set_mailtype("html");
    $msg = $this->load->view('sample_html',$data,TRUE);
    $this->email->message($msg);
    $this->email->send();
}


Try this one

您正在使用數據數組($ data)到視圖,但沒有為其分配值,只需將任何值分配給數組以避免錯誤,

$data['logo_img'] = 'images/logo.png';     // add this line before loading the view

此徽標圖片位於視圖sample_html中的$ logo_img中...

使用PHPmailer 它會幫助你。 我也用它。 您可以從此處獲取有關PHPmailer的所有信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM