我使用codeigniter電子郵件類來在用戶註冊到我的網站或在我的網站內執行某些活動時發送電子郵件。在Codeigniter中使用HTML郵件模板
問題是,在下面這個簡單的代碼中,我只能發送非常簡單的HTML電子郵件。而且我將不得不將整個HTML消息傳遞給函數。有什麼辦法可以讓我可以在函數本身中加載整個模板,只需傳遞一條消息放在模板中,就像我們在帶有視圖的codeigniter中一樣。
$message = 'Thank you for your order \n';
$message .= 'We will contact you soon';
$this->email($message);
public function email($message = NULL){
$this->load->library('email');
$this->email->mailtype('html');
$this->email->from('[email protected]', 'Sohan Kc');
$this->email->to('[email protected]');
$this->email->subject('Email Test');
$this->email->message($message);
$this->email->send();
}
我建議圍繞郵件功能做一個包裝,這樣你可以更新你的codeigniter郵件沒有問題,並保持最新 – MKroeders