
<?php
// configure
$from = 'New Inquiry <delhi@daylightlogistics.in>';
$sendTo = '<daylightlogis@gmail.com>';
$subject = 'New message from  DAYLIGHT';
$fields = array('name' => 'Name', 'email' => 'Email', 'mobile' => 'Mobile Number', 'move_from' => 'Move From', 'move_to' => 'Move To', 'item_list' => 'Item List');
if(isset($_POST['name']) && isset($_POST['mobile']) && $_POST['mobile'] != '' && $_POST['name'] != ''){
    try
    {
        $emailText = "You have new inquiry mail form  DAYLIGHT\n=============================\n";

        foreach ($_POST as $key => $value) {

            if (isset($fields[$key])) {
                $emailText .= "$fields[$key]: $value\n";
            }
        }


        mail($sendTo, $subject, $emailText, "From: " . $from);

        $okMessage = '';

        $responseArray = array('type' => 'success', 'to' => $okMessage);
    }
    catch (\Exception $e)
    {
        $errorMessage= '';
        $responseArray = array('type' => 'danger', 'to' => $errorMessage);
    }

    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        $encoded = json_encode($responseArray);

        header('Content-Type: application/json');

        echo $encoded;
    }
    else {
        echo $responseArray['to'];
    }

} else {echo 'oops something want wrong';} ?>