2016-10-03 41 views
1

您好,我使用codeigniter控制器發送電子郵件後,從數據庫中獲取數據。但問題是,當電子郵件到達$this->email->initialize($config);,同時調試它與錯誤Codeigniter控制器顯示錯誤

Severity: Notice

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'] = '[email protected]'; 

      $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('[email protected]', '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

你在使用'$ email'的地方? –

+0

@OwaisArain沒有問題,這就是問題 – Aurora

+0

'行號:563' – devpro

回答

2

您裝入的控制器後,您不能加載一個笨庫或模型,它打破這樣,如果你第一次加載您的電子郵件庫和模型,然後加載您payment控制器,它應該工作,如何這應該。

0

嘗試使用數組初始化庫。

$config = array(
    'protocol' => 'smtp', 
    'smtp_host' => 'ssl://smtp.gmail.com', 
    'smtp_port' => 465, 
    'smtp_timeout' => '7', 
    'smtp_user' => '[email protected]', 
    'smtp_pass' => '#########', 
    'charset' => 'utf-8', 
    'newline' => "\r\n", 
    'mailtype' => 'text', 
    'validation' => TRUE 
); 

$this->load->library('email', $config); 
+0

現在''this-> email->('[email protected]','aurora exchange')在這一行中給我提供了同樣的錯誤;'' – Aurora