0

my php code is

<?php
if(!session_id()) {
    session_start();
}
error_reporting(0);

if (isset($_REQUEST['action'])) {
    if ($_REQUEST['action'] == "email_server_responce") {
        $ourMail = "xyz@gmail.com"; //Insert your email address here
        $pre_messagebody_info = "";
        $errors = array();
        $data = array();
        parse_str($_REQUEST['values'], $data);

        $result = array(
            "is_errors" => 0,
            "info" => ""
        );

        if (!empty($errors)) {
            $result['is_errors'] = 1;
            $result['info'] = $errors;
            echo json_encode($result);
            exit;
        }

        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers.= 'Content-type: text/html; charset=UTF-8' . "\r\n";
        $headers.= "From: ".$data['email']."\r\n";
        $pre_messagebody_info.="<strong>Name</strong>" . ": " . $data['name'] . "<br />";
        if (! empty($data['email']) ) {
            $pre_messagebody_info.="<strong>E-mail</strong>" . ": " . $data['email'] . "<br />";
        }
        if (! empty($data['phone']) ) {
            $pre_messagebody_info.="<strong>Phone</strong>" . ": " . $data['phone'] . "<br />";
        }
        if (! empty($data['url']) ) {
            $pre_messagebody_info.="<strong>URL</strong>" . ": " . $data['url'] . "<br />";
        }
        if (empty($data['subject']) ) {
            $subject = "Website Contact Form";
        } else {
            $subject = $data['subject'];
        }
        $after_message = "\r\n<br />--------------------------------------------------------------------------------------------------\r\n<br /> This mail was sent via contact form";

        if (mail($ourMail, $subject, $pre_messagebody_info .= $category . "<strong>Message</strong>" . ": " . $data['message'] .$after_message, $headers)) {
            $result["info"] = "success";
        } else {
            $result["info"] = "server_fail";
        }
        echo json_encode($result);
        exit;
    }
} ?>

and this code is calling in html code that is

<div class="email_server_responce"></div>
    <form action="php/ram.php" method="post" class="contact-form alt clear-fix">
        <input type="text" name="name" value="" size="40" placeholder="Your Name" aria-invalid="false" aria-required="true">
        <input type="text" name="email" value="" size="40" placeholder="Your Email" aria-required="true">
        <input type="text" name="subject" value="" size="40" placeholder="Subject" aria-invalid="false" aria-required="true">
        <textarea name="message"  cols="40" rows="3" placeholder="Your Message" aria-invalid="false" aria-required="true"></textarea>
        <input type="submit" value="Send" class="cws-button border-radius alt">
    </form>
    <!--/contact-form -->
</div>

when the user hits the submit button it has to be send a mail to xyz@gmail.com. But i'm not getting Email when I hit the submit. I Cross checked my code but not able to figured out the error. Could any one solve this ?. thanks in advance

RAUSHAN KUMAR
  • 5,846
  • 4
  • 34
  • 70
dell
  • 21
  • 8

0 Answers0