Welcome Guest, Not a member yet? Register   Sign In
Codeigniter controller showing error
#1

I am using codeigniter controller to send emails, after getting data from the db. But the problem is when the email reaches $this->email->initialize($config); while debugging it crashes with the error

Severity: Notice

Message: Undefined property : Invoice::$email

Line Number: 563

Everything looks pretty fine, and I normally use this email functionality in a lot of places. But I cannot figure out the error. Here is the code in the controller.

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); 
        }
    }
Reply
#2

This function is in your Invoice class right? Does it have a property (variable) called $email?

class Invoice {
public $email = \Config\Services:email();

public function sendReminderForUnpaidInvoice() {
// some code
$this->email->initialize($config); // line 563
// more code
}
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB