0

I want to send a mail from the html form and I have separately written script for that. Below is my js code:

var IUsername       = $("#IUsername").val();
var NEmail          = $("#IEmail").val();
var IMsg            = $("#IMsg").val();


$.ajax({

    url     :"script_mail.php",
    method  :"POST",
    data    :{IUsername:IUsername, NEmail:NEmail, IMsg:IMsg},

    success :function(data){

        if(data == "T"){
            fxn_CLR();
            $('#chars').text('200');
            alert(data);
        }else{
            alert(data);
        }

    }

});

and below is my php code

if(isset($_POST["IUsername"])){


        $IUsername  = $_POST["IUsername"];
        $from       = $_POST["NEmail"];
        $to         = "partap26@gmail.com";
        $subject    = "Customer Enqury";
        $headers    = "From:" . $from . "\r\n";
        $headers    .= "Reply-To: ".$IUsername. "\r\n"; 
        $headers    .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
        $message    = "Name: ".$IUsername.""; 
        $message    .= "Email: ".$from ."";
        $message    .= "Comment: ".nl2br($_POST["IMsg"]).""; 



    if(mail($to,$subject,$message,$headers)){
        echo "T";
    }else{
        echo "F";
    }

I can see T in alert... but not able to get any mail on the mentioned email id....

Alex M
  • 2,756
  • 7
  • 29
  • 35

0 Answers0