Fatal error when trying to get admin email on contact form

Question

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:

<?php
$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?

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/fatal-error-when-trying-to-get-admin-email-on-contact-form/">

Fatal error when trying to get admin email on contact form</a>
0
, Forza 1 month 0 Answers 32 views 0

Leave an answer