Hello i have a mail form page. I am getting the value from my form but my mail function is not sending the mail. can any one help me? the code is below: <?php $to=$_POST['hemail']; $from=$_POST['from']; $sub=$_POST['hatitle']; $message=$_POST['message']; mail($to,$sub,$message,$from); echo"<script>alert (\"You Mail has been send\");history.go(-1)</script>"; else echo "<span class='red'>Failed to send the E-mail from $mail_sub to $mail_to</span>"; ?> Code (markup):
is it give you an error message or what? Maybe your server mail setting? anyway.. your codes is erroneous.. there's an 'else' without 'if' block
sorry the code is : <?php $to=$_POST['hemail']; $from=$_POST['from']; $sub=$_POST['hatitle']; $message=$_POST['message']; if (mail($to,$sub,$message,$from)) echo"<script>alert (\"You Mail has been send\");history.go(-1)</script>"; else echo "<span class='red'>Failed to send the E-mail from $mail_sub to $mail_to</span>"; ?> im getting the msg "failed to send E mail." Its not sending the mail. Can u pls tell me wats the problem?
where did you test your script? in your localhost on in your webhost? do you have mailserver installed?
i am trying it in my webhost. I am new in php i m not sure about the mailserver. how can i check and fix this problem? can u pls tell?
free webhost or paid? usually, free webhost disabled your php mail function. can you post your phpinfo() here?