我在Codeigniter框架中工作。我已经使用其电子邮件库编写了发送电子邮件代码,如下所示:
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('info@webbrainstechnologies.com', 'Instagram Shop');
$content = array(
'user_id' =>$user_id,
'first_name' =>$this->input->post('first_name'),
'last_name' =>$this->input->post('last_name'),
'mobile' =>$this->input->post('mobile_no'),
'email' =>$this->input->post('email'),
'address' =>$this->input->post('address'),
'payment_type' =>$this->input->post('payment_type'),
'comment' =>$this->input->post('comment'),
'order_date' =>date("Y-m-d h:i:sa")
);
$data['content'] = $content;
$this->email->to($to); // replace it with receiver mail id
$this->email->subject("Invoice"); // replace it with relevant subject
$body = $this->load->view('buyer/invoice',$data,TRUE);
$this->email->message($body);
$this->email->send();
我在视图文件中使用$ data [' content']作为
$content['first_name']
在视图文件中,我发送一些我想通过电子邮件发送的动态值。 但是在邮件中它给出了一个错误,比如给定的变量没有定义。
那我该怎么办呢?
答案 0 :(得分:0)
使用此:
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('info@webbrainstechnologies.com', 'Instagram Shop');
$data = array(
'user_id' =>$user_id,
'first_name' =>$this->input->post('first_name'),
'last_name' =>$this->input->post('last_name'),
'mobile' =>$this->input->post('mobile_no'),
'email' =>$this->input->post('email'),
'address' =>$this->input->post('address'),
'payment_type' =>$this->input->post('payment_type'),
'comment' =>$this->input->post('comment'),
'order_date' =>date("Y-m-d h:i:sa")
);
$this->email->to($to); // replace it with receiver mail id
$this->email->subject("Invoice"); // replace it with relevant subject
$body = $this->load->view('buyer/invoice',$data,TRUE);
$this->email->message($body);
$this->email->send();
在您看来,使用直接$user_id
等等。