0

I'm trying to figure out why my form is not sending when it's in MAMP local host or hosted live on my site. Everything looks right to me but for whatever reason, I'm not getting an email sent to me.

This is my form:

<form action="assets/php/mail.php" method="post">
    <div class="row">
        <div class="col-md-12">
            <input required class="bg-athens-gray px-4" type="text" name="name" aria-required="true" aria-invalid="false" placeholder="First Name" required>
        </div><!-- /.col-md-12 -->
        <div class="col-md-12">
            <input required class="bg-athens-gray px-4" type="email" name="email" aria-required="true" aria-invalid="false" placeholder="Your email address" required>
        </div><!-- /.col-md-12 -->
        <div class="col-md-12">
            <textarea required class="bg-athens-gray px-4" cols="10" rows="4" name="message" aria-required="true" aria-invalid="false" placeholder="Message" required></textarea>
        </div><!-- /.col-md-12 -->
        <div class="col-md-12">
            <input type="submit" value="SEND MESSAGE" class="font-size-14 ltr-sp-2">
        </div><!-- /.col-md-12 -->
    </div><!-- /.row -->
</form>

This is what's right after the body tag of my mail.php page, which is replicating most of the contact page. I'm using it to confirm that a form has been submitted while keeping the webpage looking the same.

<body>
    <?php
            $userName       = $_POST['name'];
            $userEmail      = $_POST['email'];
            $userMessage        = $_POST['message'];
            $to             = "myemail@websiteaddress.com";
            $subject        = "Email from contact page";
            $body           = "Information Submitted:";
            $body .= "\r\n Name: " . $userName;
            $body .= "\r\n Email: " . $userEmail;
            $body .= "\r\n Message: " . $userMessage;
            mail($to, $subject, $body);
    ?>
    ...
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Matt Brody
  • 1,473
  • 3
  • 14
  • 23
  • I have gone through other people's answers on this but haven't found the answer yet. I've tried different email addresses as well and that didn't work. – Matt Brody Oct 22 '19 at 21:54
  • What are the hosting provider's requirements for this, if applicable? For example, a hosting provider may have a specific path to include Mail.php from per server. – GetSet Oct 22 '19 at 21:58
  • Place your `mail()` function inside an `if/else`. If this goes to `if` with an echo'd message, then mail did its job. If it goes to `else/error`, then it failed and you need to find out why. – Funk Forty Niner Oct 22 '19 at 22:16

0 Answers0