我尝试通过CodeIgniter邮寄我的客户,就像我在注册约会时一样,通过在客户表格中找到客户电子邮件发送电子邮件。来自其他桌子的其他东西发送电子邮件进行确认。
这是我的App_model.php
public function send_mail()
{
$query=$this->db
->select('*, employee.name_emp as emp_name, customer.name as
cust_name, servicetype.name_set as s_name, serviceplan.price as
p_rice')
->from('appointment')
->join( 'customer', 'customer.id= appointment.name_app')
->join( 'servicetype', 'servicetype.id_set= appointment.sertype')
->join( 'employee', 'employee.id_emp= appointment.emp')
// ->join('serviceplan', 'serviceplan.price=appointment.price_app')
->get();
return $query->result();
}
这是我的App_controller
function sendmail($appointment_id){
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx',
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
// Set to, from, message, etc.
$this->load->model('App_model');
$appointment=$this->App_model->send_mail($appointment_id);
// print_r($appointment);
//exit();
$message=Array(
$message=Array(
'Name'=>$appointment[0]->cust_name,
'Service Type'=>$appointment[0]->s_name,
// 'Service Plan'=>$appointment->p_rice,
'Employee'=>$appointment[0]->emp_name,
'Date'=>$appointment[0]->date,
'Time'=>$appointment[0]->time
);
$this->email->from('xxx', 'xxx');
$this->email->to('xxx');
$this->email->subject('Confirmation of Your Appointment');
$this->email->message($message);
$result = $this->email->send();
}
我在print_r($appoinment)
&它显示所有数据,但是当我运行整个程序时它没有显示任何错误&仍然邮件无效
遇到PHP错误 严重性:注意
消息:尝试获取非对象的属性
文件名:controllers / App_controller.php
感谢您的帮助
答案 0 :(得分:0)
您正在将变量从控制器传递到此处的模型
$appointment=$this->App_model->send_mail($appointment_id);
但在模型中你没有收到任何变量。
public function send_mail()
将其更改为
public function send_mail($appointment_id)
你需要在where条件中使用传递的$ appointment_id,否则它会返回表中的所有行。