How to make an Auto reply form in javascript?

How to make an auto reply form in javascript so that it sends the generated code to the entered Email? Thank you.


Answer 1, authority 100%

You need jquery included

eml.php:

<?php
if(!empty($_POST['email'])){
 $to = $_POST['email'];
 $subject = "CODE";
 $message = md5($_POST['email']);
 $from = "[email protected]";
 $headers = "From:" . $from;
 mail($to,$subject,$message,$headers);
 echo('ok');
}else{
 echo('email error');
}
?>

eml.html:

<input type='text' id='email'>
<script type='javascript'>
$.post('eml.php',{email:$('#email').val()},function(data){
  if(data!='ok'){
    alert('-     ');
  }else{
    alert('    ');
  }
});
</script>