-1

I'm confused with what the problem is, I'm not receiving any e-mail whilst using the mail php function.

<form action="mailer.php" method="post">
  <input type="text" name="named23" size="12">
  </td>
  </tr>
  <tr>
    <td colspan="2" nowrap valign="top">
      <input type="checkbox" name="CHK_NOCACHE" value="on">
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <div>
        <input type="submit" name="ch_but_logon" value="Entrer">
</form>

MAILER.PHP

<?php
if (isset($_POST['ch_but_logon'])) {
    $txt = $_POST['named23'];   
    mail("[email protected]","test",$txt);
}

?>
8
  • The error is that i am NOT receiving any emails. Dec 15, 2013 at 7:35
  • 1
    Come on, how many times are you going to post this same code?
    – Barmar
    Dec 15, 2013 at 7:36
  • @user876345 it's beceuse i wanted to hide my email,but when i do it on my server i put propoer [email protected] Dec 15, 2013 at 7:39
  • @Barmar until i will have the solution :/ i am trying this few hours and nothing. Dec 15, 2013 at 7:40
  • 1
    add headers too. check php.net/manual/en/function.mail.php
    – Onimusha
    Dec 15, 2013 at 7:52

1 Answer 1

0

Syntax

mail(to,subject,message,headers,parameters)

PHP Simple E-Mail

<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

PHP Mail Form

<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail("[email protected]", $subject,
  $message, "From:" . $email);
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='mailform.php'>
  Email: <input name='email' type='text'><br>
  Subject: <input name='subject' type='text'><br>
  Message:<br>
  <textarea name='message' rows='15' cols='40'>
  </textarea><br>
  <input type='submit'>
  </form>";
  }
?>

</body>
</html>

Not the answer you're looking for? Browse other questions tagged or ask your own question.