Con
Yet another WordPress dev

Debugging WordPress Contact Form 7 send submission problems

If you have trouble with Contact Form 7 aborting submissions and it claiming "Cannot send..."
You can use this code to debug it:
(Thank you: Bernhard Kau)

// a) The debug function to generate the console error message. 

function debug_cf7_add_error( $items, $result ) 
{
      if ( 'mail_failed' == $result['status'] ) {
            // invoke global phpmailer object
            global $phpmailer;
            // append error info to ajax response.
            $items['errorInfo'] = $phpmailer->ErrorInfo;
        }
    return $items;
}
add_action( 'wpcf7_ajax_json_echo', 'debug_cf7_add_error', 10, 2 );


// b) Did not work for me. 
add_filter('wpcf7_spam', '__return_false');

// c) There is another filter for the boolean used in the control statement. This successfully disabled the spam check of CF7 for me. 
add_filter('wpcf7_skip_spam_check', '__return_true');
  • a) used to diagnose the error via:

  • b) was the snippet I tried first. The filter exists but it did not work for me so I used c).

That did it. Happy debugging.

keep reading?

Leave the first comment