<?php
$response           = array();
$response['status'] = 'warning';

// Contact form
if ( ( isset( $_POST['cf-1-name'] ) && $_POST['cf-1-name'] != "" ) && ( isset( $_POST['cf-1-phone'] ) && $_POST['cf-1-phone'] != "" ) && ( isset( $_POST['cf-1-email'] ) && $_POST['cf-1-email'] != "" ) && ( isset( $_POST['cf-1-question'] ) && $_POST['cf-1-question'] != "" ) ) {
    $to      = 'your@email.com'; // Your email
    $subject = 'Contact form';   // E-mail subject
    $message = '
            <html>
                <head>
                    <title>' . $subject . '</title>
                </head>
                <body>
                    <p>Name: ' . $_POST['cf-1-name'] . '</p>
                    <p>Phone no.: ' . $_POST['cf-1-phone'] . '</p>
                    <p>Email: ' . $_POST['cf-1-email'] . '</p>
                    <p>Question: ' . $_POST['cf-1-question'] . '</p>
                </body>
            </html>';
    $headers = "Content-type: text/html; charset=utf-8 \r\n"; // Charset
    $headers .= "From: Hosco <your@email.com>\r\n";           // Your name and email
    
    if ( mail( $to, $subject, $message, $headers ) ) {
        $response['status'] = 'success';
    } else {
        $response['status'] = 'error';
    }
}

echo json_encode( $response );
?>