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

<?php
// Send Message
if(isset($_REQUEST['submit'])) {
    if(nt_get_option('advance', 'recaptchar_site_key') && nt_get_option('advance', 'recaptchar_secret_key')) {
        require_once(THEME_LIBS_DIR.'/recaptchalib.php');
        $privatekey = nt_get_option('advance', 'recaptchar_secret_key');
        $resp = recaptcha_check_answer ($privatekey,
                                     $_SERVER["REMOTE_ADDR"],
                                     $_POST["recaptcha_challenge_field"],
                                     $_POST["recaptcha_response_field"]);
        $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( ’email@address.com’, $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()


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: