【发布时间】:2016-10-03 09:51:09
【问题描述】:
您好,在从数据库获取数据后,我正在使用 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);
}
}
【问题讨论】:
-
你在哪里使用
$email? -
@OwaisArain 不,这就是问题所在
-
Line Number: 563在哪里 -
@devpro $this->email->initialize($config); // 第 563 行
-
@OwaisArain 我在很多控制器中都使用这种格式,并且它们都可以工作,这个突然说我正在使用 $email,但我显然不是。
标签: php codeigniter email