Click here to Skip to main content
15,918,617 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.

     <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">
      <label for="name">Your Name <span class="red">*</span></label>
      <input id="name" name="name" class="text" />
      <label for="email">Your email <span class="red">*</span></label>
      <input id="email" name="email" class="text" />
      <label for="subject">Subject</label>
      <input id="subject" name="subject" class="text" />
      <label for="message">Message <span class="red">*</span></label>
      <textarea id="message" name="message" rows="6" cols="50"></textarea>
    <li class="buttons">
      <input type="image" name="imageField" id="imageField" src="images/send.gif" class="send" />
      <div class="clr"></div>


if(!$_POST) exit;

$email = $_POST['email'];


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

$mail_to_send_to = "";
$your_feedbackmail = "";
$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");

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

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