unset($_POST['recaptcha']);
// Form creation
$MAX_LENGTH_NAME = 30;
$MAX_LENGTH_SUBJECT = 70;
$MAX_LENGTH_MESSAGE = 250;
$REASONS = array('enquiry' => 'Consultas', 'complaint' => 'Reclamos', 'difussion' => 'Bandas/Difusión', 'other' => 'Otros');
$form = new Form(array('full_name' => array('label' => 'Nombre/s', 'type' => 'string', 'required' => true, 'maxlength' => $MAX_LENGTH_NAME), 'email' => array('label' => 'Correo electrónico', 'type' => 'email', 'required' => true), 'reason' => array('label' => 'Motivo', 'type' => 'string', 'required' => true, 'select' => $REASONS), 'subject' => array('label' => 'Asunto', 'type' => 'string', 'required' => true, 'maxlength' => $MAX_LENGTH_SUBJECT), 'message' => array('label' => 'Mensaje', 'type' => 'string', 'required' => true, 'maxlength' => $MAX_LENGTH_MESSAGE)));
$errors = $form->validate_whitelist();
if (!empty($errors)) {
    Response::json(400, $errors);
}
$errors = $form->validate_required();
if (!empty($errors)) {
    Response::json(400, $errors);
}
$form->fill_values();
$errors = $form->validate_format();
if (!empty($errors)) {
    Response::json(400, $errors);
}
// Get form values
$full_name = $form->value('full_name');
$email = $form->value('email');
$reason = $form->value('reason');
$subject = $form->value('subject');
$message = $form->value('message');
// Message template
$message_body = file_get_contents('../templates/_email_contact.html');
$message_body = str_replace(array('{{ full_name }}', '{{ email }}', '{{ reason }}', '{{ subject }}', '{{ message }}'), array($full_name, $email, $REASONS[$reason], $subject, $message), $message_body);
// Mail build
$mailer = new SendGrid(Config::$SENDGRID_USERNAME, Config::$SENDGRID_PASSWORD, Config::$SENDGRID_OPTIONS);