Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29748

Can't get my contact form to actually work [duplicate]

$
0
0

I'm quite new to coding in general and JUST started trying to use PHP for a uni project.

I've made an extremely easy HTML contact form, and haven't bothered styling it (as it's just a test) My problem is now, that I've tried to get it actually send an email via. PHP. The contact form itself works, but it just doesn't send an email to the mail I've chosen in PHP

<!DOCTYPE html><html><head><meta charset="utf-8"><title> Contact form tutorial </title></head><body><main><p> SEND E-MAIL </p><form class="contact-form" action="contactform.php" method="post"><input type="text" name="name" placeholder="Full name"><input type="text" name="mail" placeholder="Your e-mail"><input type="text" name="subject" placeholder="Subject"><textarea name="message" placeholder="Message"></textarea><button type="submit" name="submit"> SEND MAIL </button></form></main></body></html>

<?php

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

  $mailTo = "hse-g01@haarslev-esport.dk";
  $headers = "From: ".$mailFrom;
  $txt = "You have recieved an e-mail from ".$name.".\n\n".$message;

  mail($mailTo, $subject, $txt, $headers);
  header("Location: index.html?mailsend");
}

Viewing all articles
Browse latest Browse all 29748

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>