Call to undefined function wp_mail Call to undefined function wp_mail wordpress wordpress

Call to undefined function wp_mail


please add below code in you file. where you have called wp_mail() function.

Add this code top of your file.

require_once("../../../wp-load.php");

or change your function wp_mail() to mail()


You are calling function wp_mail() which can be included by wp-load.php .

require_once("wp-load.php");


Solution provided by Tonny works for me. My code:

function your_function_name() {        $to =' your@email.com';        $subject = 'The subject';        $body = 'The email body content';        $headers = array('Content-Type: text/html; charset=UTF-8');        wp_mail( $to, $subject, $body, $headers );}add_action( 'wp_loaded', 'your_function_name' );