0

Hello i am fensing a problem with my form sending to email. I have created a form to send values to my emal, when in press Send button it tells me that message is sent but i can't see at my yahoo or gmail email, i am receiving nothing ...

here is my form with php code:

<?php 
$ToEmail = 'mr_sergios@yahoo.com'; 
$EmailSubject = 'Site contact form'; 
 $mailheader = "From: ".$_POST["email"]."\r\n"; 
 $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
 $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$MESSAGE_BODY = "Name: ".$_POST["name"].""; 
$MESSAGE_BODY .= "Email: ".$_POST["email"].""; 
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"]).""; 
  mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?>

<?php 
if ($_POST["email"]<>'') { 
$ToEmail = 'mr_sergios@yahoo.com'; 
$EmailSubject = 'Site contact form'; 
$mailheader = "From: ".$_POST["email"]."\r\n"; 
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$MESSAGE_BODY = "Name: ".$_POST["name"].""; 
$MESSAGE_BODY .= "Email: ".$_POST["email"].""; 
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"]).""; 
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 
   Your message was sent
      <?php 
   } else { 
  ?> 
    <form action="test.php" method="post">
   <table width="400" border="0" cellspacing="2" cellpadding="0">
  <tr>
     <td width="29%" class="bodytext">Your name:</td>
  <td width="71%"><input name="name" type="text" id="name" size="32"></td>
    </tr>
    <tr>
     <td class="bodytext">Email address:</td>
    <td><input name="email" type="text" id="email" size="32"></td>
     </tr>
      <tr>
   <td class="bodytext">Comment:</td>
        <td><textarea name="comment" cols="45" rows="6" id="comment"  
  class="bodytext">      
   </textarea></td>
  </tr>
  <tr>
   <td class="bodytext"> </td>
    <td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
    </tr>
       </table>
   </form> 
 <?php 
  }; 
  ?>
serii
  • 5
  • 4

4 Answers4

0

You probably don't have the correct SMTP settings set up in your php.ini. I'd recommend using something other than mail() anyway, as it's more likely to be reliable. Try something like this instead.

Either that, or it's just landed in your spam folder.

Community
  • 1
  • 1
Alfo
  • 4,801
  • 9
  • 38
  • 51
0

Are you sending it from Linux? If yes, please check /var/log/mail.err and see if the SMTP throws any errors.

For Windows it might be necessary to install a SMTP server, like Mercury SMTP

Vasile Goian
  • 425
  • 5
  • 9
  • Try using Mercury SMTP. I'm not really familiar with Windows environment but this should do the job. Official website: http://www.pmail.com/ – Vasile Goian Mar 09 '13 at 17:11
0

Have you considered using PHP Mailer Class?

The example below is a form that submits to itself on the same page just paste the below at the very top of your contact page. Download and include your class.

require_once('class.phpmailer.php');
$address = "you@youremail.com";
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$subject = htmlspecialchars($_POST['subject']);
$comment = htmlspecialchars($_POST['comment']);

$mail  = new PHPMailer(); // defaults to using php "mail()"
$body = $comment;
$mail->AddReplyTo($email,$name);
$mail->SetFrom($email,$name);
$mail->AddReplyTo($email,$name);
$mail->AddAddress($address, "Your Name");
$mail->Subject = $subject;
$mail->MsgHTML($body);
if(isset($_POST['submit']))
{
$mail->Send();
}
0

Consider using this library: http://code.google.com/a/apache-extras.org/p/phpmailer/

It's extremely easy to setup and use, also gives you details in case of an error.

Manish
  • 4,903
  • 1
  • 29
  • 39