Hi im using this function by Wordpress in a Cron webpage and is throwing this error on my email
Fatal error: Call to undefined function wp_mail() in /home/meusite/public_html/wp-content/themes/escotec/page-cron.php on line 33
Here the code
foreach($inscricoes as $key => $item){
    $emailSent = false;
    $emailTo = "$item->getEmail()";
//echo "..1";
    $subject = '[Escotec]: Dados para pagamento de inscrição ';
    $body = "Parabéns $inscricao->nome, sua inscrição no curso ".$item->getTurmas()[0]->getCurso()->getNome()." foi efetuada. <p>Para concluir o pagamento da inscrição clique no link abaixo ou cole-o diretamente na barra de endereços de seu Navegador: </p><br>";
    $body .= "<a href=\"http://escotecnordeste.com.br/pagamento/?email=".$item->getEmail()."&pedido=".$item->getPagamentoId()."\" target=\"_blank\">http://escotecnordeste.com.br/pagamento/?email=".$item->getEmail()."&pedido=".$item->getPagamentoId()."</a>";
    $headers = 'From: Escotec Nordeste <[email protected]>' . "\r\n" . 'Reply-To: ' . '[email protected]';
    wp_mail($emailTo, $subject, $body, $headers);
    $emailSent = true;
// http://escotecnordeste.com.br/pagamento/[email protected]&pedido=11
// Codificar envio do e-mail
    if ($emailSent) {
    // Atualizar registro do pedido para email_enviado = 'S'
        InscricaoDAO::RegistraEnvioEmail($item->getPagamentoId());
    }
}
Ty for help
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 =' [email protected]';
        $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' );
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With