0
<form action="" method="post">
    <input placeholder="Ονομα" name="name" type="text" required />
    <input placeholder="Email" name="mail" type="email" required />
    <input placeholder="Θεμα" name="subject" type="text" required />
    <textarea name="message" placeholder="Μήνυμα"></textarea>
    <input class="formBtn" name="submit" type="submit" />
  </form>
  <?php

if (isset($_POST['submit'])) {
  $name = $_POST['name'];
  $subject = $_POST['subject'];
  $mailfrom = $_POST['mail'];
  $message = $_POST['message'];

  $mailTo = "myemail";
  $headers = "From: ".$mailfrom;
  $txt = "You got a new mail from ".$name.".\n\n".$message;

  mail($mailTo, $subject, $txt, $headers);
  header("Location: form.php?mailsend");
}
?>

myemail is just an example. The original code has my personal email.

So when running this code and filling out the form it reaches to an end(displayes the mailsend message).But when i search through my emails is not there. I tried like 30 times and none of them came to my mailbox Thank you.

  • For the mail functions to be available, PHP requires an installed and working email system. The program to be used is defined by the configuration settings in the php.ini file. – Richard Feb 24 '18 at 22:47
  • i thought php comes already with an email system.. so if i try it on a server it should be working? – PHPStudent123 Feb 24 '18 at 22:49
  • Is there any error logged to your servers error log? If you cannot find it, you should at least consider to use a more verbose error level such that an error is logged to the browser. A script usually does not stop in between without any reason – Nico Haase Feb 24 '18 at 22:58

0 Answers0