Fatal error when trying to get admin email on contact form


I’m building a contactform that needs to send all queries to the admin mail adress.

The php file which processes the entered data and sends the email has only contains this code:

$admin_email = get_option('admin_email');

if($_POST["name"] != "" && $_POST["contact"] != ""  && $_POST["comments"] != "")
    echo "Uw bericht is verzonden! ";
    $name = $_POST["name"];
    $contactOption = $_POST["contactoption"];

    $msg = "Bericht afkomstig van: n";
    $msg .= "Naam: " .$name;
    $msg .= "nE-mail of Telefoonnummer: " .$contactOption;
    $msg .= "nn";
    $msg .= "Bericht: n";
    $msg .= $_POST["comments"];
    $msg .= "nn";

    $subject = utf8_decode("Bericht via Contactformulier");
    $headers = utf8_decode("From: " .$name."rn");

    mail($mailTo, $subject, utf8_decode($msg), $headers);


The problem is, I cannot use get_option or get_bloginfo to get the admin mail adress. This allways returns a fatal error.

This file resists in my childtheme folder. Why can’t I use these functions? I’ve also tried adding get_header() and get_footer() to the file, but these functions are also not recognized.

I’m relatively new to wordpress. Am I missing something obvious here?

, Forza 9 months 0 Answers 54 views 0

Leave an answer