public function post_contact() { $val = Validation::forge(); $val->add_callable('MyRules'); $val->add_field('name', 'Name', 'required|max_length[100]'); $val->add_field('email', 'Email', 'required|valid_email|max_length[255]'); $val->add_field('subject', 'Subject', 'required|max_length[255]'); $val->add_field('message', 'Message', 'required|max_length[1000]'); if ($val->run()) { $props = array('to' => $val->validated('email'), 'subject' => Model_Service_Util::mb_trim($val->validated('subject')), 'content' => array('name' => Model_Service_Util::mb_trim($val->validated('name')), 'body' => Model_Service_Util::mb_trim($val->validated('message'))), 'view' => 'contact'); Model_Service_Mail::send_mail($props); $this->data['success'] = 'Gửi tin nhắn thành công'; } else { $this->data['errors'] = $val->error_message(); } return $this->response($this->data); }
public static function send_mail($option = null) { $option = json_decode(base64_decode($option)); \Model_Service_Mail::send($option); }