public function action_email() { $session = Session::instance(); $bill_id = $this->request->param('options'); $bill = new Bill($bill_id); if ($bill->send_mail()) { $session->set('message', 'Mail sent for bill #' . $bill_id); } else { $session->set('error', 'Mail for bill #' . $bill_id . ' failed!'); } $this->redirect(); // if email sent then update bills.invoice_sent with CURRENT_TIMESTAMP }