$headers .= 'From: marcz@lab1521.com' . "\r\n"; return mail($this->email, $this->subject, $this->message, $headers); } } $emailTemplate = '<table> <tr><th>First Name</th><td>{{nameFirst}}</td></tr> <tr><th>Last Name</th><td>{{nameLast}}</td></tr> <tr><th>Email</th><td>{{email}}</td></tr> <tr><th>Phone</th><td>{{phone}}</td></tr> <tr><th>Message</th><td></td></tr> <tr><td colspan="2">{{message}}</td></tr> </table> '; $antiSpam = new AntiSpam(); $mailer = new Mailer(); $mailer->to('*****@*****.**'); $mailer->subject('Online Enquiry To VineyardForSale'); $mailer->setTemplate($emailTemplate); if (isset($_POST['antiSpamAnswer']) && isset($_POST['antiSpamToken'])) { $form = new ContactForm(); $form->setFields(array('nameFirst' => 'required|sanitize', 'nameLast' => 'required|sanitize', 'email' => 'required|email', 'phone' => 'required|sanitize', 'message' => 'required|sanitize', 'antiSpamAnswer' => 'required|sanitize', 'antiSpamToken' => 'required|sanitize')); $form->setSource($_POST); $form->setFilter(array($antiSpam, 'answer'), array('antiSpamAnswer', 'antiSpamToken')); $validation = $form->validate(); if ($validation['success']) { $mailer->fillTemplate($form->getFields()); $mailer->send(); } JSON::output($validation); } JSON::output($antiSpam->question());