Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29755

wp_mail() function is not sending emails while in functions.php

$
0
0

Here is a function I made that sends an email with verification code to user email. I am calling this function once someone submits the registration form.

function send_verification_email($email, $code) {    $subject = 'Verify Your Email';    $body = $code;    $headers = array('Content-Type: text/html; charset=UTF-8');    $headers[] = 'From: Example <no-reply@example.com>';    wp_mail( $email, $subject, $body, $headers );}

If I use these codes in the actual page template, it works properly. Just not in functions.php. I've checked if $email, $code parameters are being passed properly, it is.

I've checked postfix log, there was no email even created in postfix. So basically wp_mail() is fully dormant in functions.php. Did anyone faced this problem before? Is there any way I can make this work in functions.php file?

Thanks in advance


Viewing all articles
Browse latest Browse all 29755

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>