0

just created a basic php file for email submission, but when i hit submit, i don't receive an email at all. I really can't spot my mistake - i'm using VS Code & Xampp.

this is my html form:

<section class="contact-section info-block" id="contact">
                <div class="contact-wrapper">
                    <div class="contact-heading">
                        <h2 class="section-heading"> Contact </h2>
                    </div>
                    <div class="contact-form">
                        <form id="contact-form" method="post" action="contact-handler.php">
                            <p>
                                <input name="name" type="text" class="form-control" placeholder="name" required>
                            </p>
                            <p>
                                <input name="email" type="email" class="form-control" placeholder="email adress" required>
                            </p>
                            <p>
                                <textarea name="message" class="form-control" placeholder="message" row="4" required></textarea>
                            </p>
                            <input type="submit" class="form-control submit" value="Submit Message">
                        </form>
                    </div>
                </div>
            </section>

and here is my php file:

<?php
    $name = $_POST['name'];
    $visitor_email = $_POST['email'];
    $message = $_POST['message'];

    $email_from = 'myWebsite.com';
    $email_subject ='New Submission';
    $email_body = "User Name: $name.\n". 
                    "User Email: $visitor_email.\n".
                        "User Message: $message.\n";

    $to = "blabla@MyEmailadress.com";

    $headers = "From: $email_from\r\n";

    $headers .= "Reply-To: $visitor_email\r\n";

    mail($to,$email_subject,$email_body,$headers);

    header("Location: index.html");
?>

Can someone spot the issue? I'm also thankful for improvements because i'm a beginner and still learning. Thanks in advance!

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
FloatingGoat
  • 105
  • 1
  • 7
  • https://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost – j08691 Apr 24 '20 at 18:07
  • Does this answer your question? [How to configure XAMPP to send mail from localhost?](https://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost) – Joseph Apr 24 '20 at 18:07
  • You tagged as "html-email" but haven't any "HTML" in there. – Funk Forty Niner Apr 24 '20 at 18:08
  • If that's the full email, you need to learn a thing or two about email! First, JavaScript and forms are not going to work. Second, many email clients will not consider your CSS unless it is inline. Think back to 1990's web development and do a table layout. Read up any article about it. – Nathan Apr 26 '20 at 22:18

0 Answers0