1

How can I use get_bloginfo('admin_email') in a custom PHP file located in the parent theme root directory?

I've built a custom form and a PHP mail script separately, but now I'd like to send the form data to the WP Admin email address with Bcc.

    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    $headers .= 'From: <[email protected]>' . "\r\n";
    $headers .= 'Bcc: <'. get_bloginfo('admin_email');'>'. "\r\n";

    mail("[email protected]","Form Application",$admin_email_body,$headers);

Do I need to include Wordpress functions in the PHP file?

Thanks

1 Answer 1

2

You can include the wp-load.php in your PHP file, but, I do not recommend this method. It's better you use the wp_enqueue_script().

See this article to get more information.

<?php
include "../../../wp-load.php";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Bcc: <'. get_bloginfo('admin_email') . '>'. "\r\n";


mail("[email protected]","Form Application",$admin_email_body,$headers);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.