Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php form doesn't send [closed]

Tags:

html

forms

php

When I submit my form it Dies for an unkown reason.

My form code:

    <form action="mail.php" method="post">
        <input class="invoeren" name="naamUser" type="text" placeholder="Naam" required>
        <input class="invoeren" name="nummerUser"  type="text" placeholder="Telefoonnummer" required>
        <input class="invoeren" name="onderwerpUser"  type="text" placeholder="Onderwerp" required>
        <textarea class="invoeren" type="text" name="opmerkingUser"  placeholder="Opmerking" required></textarea>           
        <button type="submit" id="contactButton">Verstuur</button>
    </form>

My mail.php file:

<?php 
    ob_start(); 

    $naamUser = $_POST['naamUser'];
    $nummerUser = $_POST['nummerUser'];
    $onderwerpUser = $_POST['onderwerpUser'];
    $opmerkingUser = $_POST['opmerkingUser'];


    $formcontent="Aanvraag formulier Domein naam \n
    Naam: $naamUser \n
    Telefoonnummer: $nummerUser \n
    Onderwerp: $onderwerpUser \n
    Opmerking: $opmerkingUser \n              
                  ";              

    $recipient = "[email protected]";

    $subject = "Terug Bellen";

    $mailheader = "From: $naamUser \r\n";

    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    ?>

I use 1 mail.php file for several index.html files, is that maybe the reason why it dies?

like image 268
Blank Avatar asked Aug 12 '26 13:08

Blank


1 Answers

"Can you answer this question by your comment? @Fred-ii- Because that's the answer, thanks! – Blank"

As per OP's request:

From: expects an email address, not a name.

  • Check your spam.

Read the manual on mail()

  • http://php.net/manual/en/function.mail.php

and another comment:

Add error reporting to the top of your file(s) right after your opening PHP tag for example

<?php error_reporting(E_ALL); ini_set('display_errors', 1); then the rest of your code, to see if it yields anything and make sure you've access to mail() and that PHP is in fact running properly.

like image 164
Funk Forty Niner Avatar answered Aug 14 '26 16:08

Funk Forty Niner