您好我在从数据库获取数据后使用codeigniter控制器发送电子邮件。但问题是当电子邮件到达$this->email->initialize($config);
时,调试时崩溃时会出现错误
Severity: Notice
Message: Undefined property : Invoice::$email
Line Number: 563
一切看起来都很好,我通常在很多地方使用这个电子邮件功能。但我无法弄清楚错误。 这是控制器中的代码。
public function sendReminderForUnpaidInvoice() {
//fetch tha data from the database
$this->load->model('invoice_page');
$foo = $this->invoice_page->get();
$result = json_decode(json_encode($foo), true);
foreach ($foo as $result){
$this->load->library('../controllers/payment');
$resultMangoPay = $this->payment->getMangopayPayinForTheInvoiceMail($result->rf_reference);
$totalAmount = ($result->gross_amount) + ($result->type_related_amount) ;
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'support@aurorax.co';
$config['smtp_pass'] = '#########';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'text'; // or html
$config['validation'] = TRUE; // bool whether to validate email or not
$this->email->initialize($config); // line 563
$this->email->from('support@aurorax.co', 'aurora exchange');
$this->email->to($result->Email);
$this->email->subject('Repayment invoice');
$this->email->message(
'Hello '.$result->Fullname.'.'."\n"
.'Here is a invoice for the next upcoming payment. '."\n"."\n"
.'Payment should be done by bank transfer to the information provided below'."\n"
.'Name :'.$resultMangoPay['OwnerName']
.'IBAN :'.$resultMangoPay['IBAN']
);
$returnvalue = $this->email->send();
if(!$returnvalue) {
return false;
} else {
// will do something here later
}
$this->email->clear(TRUE);
}
}
答案 0 :(得分:2)
加载控制器后无法加载codeigniter库或模型,它会破坏,如果先加载电子邮件库和模型,然后加载payment
控制器,它应该如何工作应该。
答案 1 :(得分:0)
尝试使用数组初始化库。
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_timeout' => '7',
'smtp_user' => 'support@aurorax.co',
'smtp_pass' => '#########',
'charset' => 'utf-8',
'newline' => "\r\n",
'mailtype' => 'text',
'validation' => TRUE
);
$this->load->library('email', $config);