繁体   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