Problem with wp_mail()

I’m trying to solve a problem in which I have various contact form not sending emails. Here’s the code:

// Send Message
if(isset($_REQUEST['submit'])) {
    if(nt_get_option('advance', 'recaptchar_site_key') && nt_get_option('advance', 'recaptchar_secret_key')) {
        $privatekey = nt_get_option('advance', 'recaptchar_secret_key');
        $resp = recaptcha_check_answer ($privatekey,
        $is_valid = $resp->is_valid;
    } else {
        $is_valid = true;

    global $nt_site_message;
    if($is_valid) {

        $from = $_REQUEST['from'];
        $phone = $_REQUEST['phone'];
        $msg = $_REQUEST['message'];
        $to = '';
        if(isset($_REQUEST['to'])) $to = $_REQUEST['to'];
        if(!$to) $to = nt_get_option('property', 'contact_email', get_bloginfo('admin_email'));

        $subject = __('Inquiry Property', 'theme_front');
        $property_id = get_post_meta( $post->ID, '_meta_id', true );
        if($property_id) {
            $subject .= ' #'.$property_id;

        $headers[] = 'From: '.$from;
        $headers[] = 'Reply-To: '.$from;
        $headers[] = 'MIME-Version: 1.0';
        $headers[] = 'Content-type: text/html; charset=utf-8';

        $message = '<strong>From</strong>: '.$from;
        $message .= '<br /><strong>Phone</strong>: '.$phone;
        $message .= '<br /><strong>Property</strong>: <a href="'.get_the_permalink().'">'.$post->post_title.'</a>';
        $message .= '<br /><br /><strong>Message</strong>: <br />'.$msg;

        wp_mail( $to, $subject, $message, $headers );
        $nt_site_message = __('Your message has been sent.', 'theme_front');
    } else {
        $nt_site_message = __('There are something wrong.', 'theme_front');
} ?>

I tried putting email variable inside $to = ”; and also inside function directly like this: wp_mail( ’’, $subject, $message, $headers );
Recaptcha isn’t working even if I set up my API correctly.

Into generated static HTML I found variable to be declared as “name” and not “id” but it isn’t working. ()
The same script is reported to work on other hosts.

Any ideas/suggestions?
Thank you

Read more here: Problem with wp_mail()

Leave a Reply

Your email address will not be published. Required fields are marked *