Click here to Skip to main content
15,029,433 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my php code to send email. I got the massage 'Message was sent, you can send another one. But email is not sending.I am Using Cpanel to host my web site. Is there any special configurations to do this? I'm new to php. Please help me.


HTML
     <h4>Please fill out the following form and we will be in touch with you soon.</h4>
<form action="mytest.php" method="post" id="contactform">
  <ol>
    <li>
      <label for="name">Your Name <span class="red">*</span></label>
      <input id="name" name="name" class="text" />
    </li>
    <li>
      <label for="email">Your email <span class="red">*</span></label>
      <input id="email" name="email" class="text" />
    </li>
    <li>
      <label for="subject">Subject</label>
      <input id="subject" name="subject" class="text" />
    </li>
    <li>
      <label for="message">Message <span class="red">*</span></label>
      <textarea id="message" name="message" rows="6" cols="50"></textarea>
    </li>
    <li class="buttons">
      <input type="image" name="imageField" id="imageField" src="images/send.gif" class="send" />
      <div class="clr"></div>
    </li>
  </ol>
</form> 


<?php

if(!$_POST) exit;

$email = $_POST['email'];

$errors=0;

if($errors==1) echo $error;
else{
    $email_from = $_POST['email'];
$email_from = "from@gmail.com";
$headers = "From: " . strip_tags( $_POST['name'] ) . "\r\n";

$mail_to_send_to = "to@gmail.com";
$your_feedbackmail = "from@gmail.com";
$sendflag = 'send';                       
if ( $sendflag == "send" )
        {
                $email = $_REQUEST['email'] ;
                $message = $_REQUEST['message'] ;
                $headers = "From: $your_feedbackmail" . "\r\n" . "Reply-To: $email" . "\r\n" ;
                $a = mail( $mail_to_send_to, "Feedback Form Results", $message, $headers );
                if ($a)
                {
                     print("Message was sent, you can send another one");
                } else {
                     print("Message wasn't sent, please check that you have changed emails in the bottom");
                }
        }
}
?>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900