Title: Fatal Error
Last modified: August 22, 2016

---

# Fatal Error

 *  Resolved [Hiranthi](https://wordpress.org/support/users/illutic/)
 * (@illutic)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/fatal-error-1394/)
 * I just saw a fatal error in my log:
 * PHP Fatal error: Cannot use object of type WP_Error as array in /…/wp-content/
   plugins/postmark-approved-wordpress-plugin/postmark.php on line 306, referer:…/
   wp-admin/edit-comments.php
 * I noticed there is no check if $response was in fact filled by the WP_Error class,
   so I changed the pm_send_mail function (at the bottom of postmark.php) a bit:
 * **Original:**
 *     ```
       function pm_send_mail($headers, $email){
       	$args = array(
       		'headers' => $headers,
       		'body' => json_encode($email)
       	);
       	$response = wp_remote_post(POSTMARK_ENDPOINT, $args);
   
       	if($response['response']['code'] == 200) {
       		return true;
       	} else {
       		return false;
       	}
       }
       ```
   
 * **What I currently use:**
 *     ```
       function pm_send_mail($headers, $email){
       	$args = array(
       		'headers' => $headers,
       		'body' => json_encode($email)
       	);
       	$response = wp_remote_post(POSTMARK_ENDPOINT, $args);
   
       	if ( is_wp_error( $response ) ) return false; // added to check whether $response is filled by WP_Error, if so: return false
   
       	if($response['response']['code'] == 200) {
       		return true;
       	} else {
       		return false;
       	}
       }
       ```
   
 * [https://wordpress.org/plugins/postmark-approved-wordpress-plugin/](https://wordpress.org/plugins/postmark-approved-wordpress-plugin/)

Viewing 1 replies (of 1 total)

 *  [mhorbul](https://wordpress.org/support/users/mhorbul/)
 * (@mhorbul)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/fatal-error-1394/#post-5432086)
 * here is my version of fixing it as $curl is not available here.
 *     ```
       --- postmark.php.origin 2015-05-19 22:34:44.728346590 -0600
       +++ postmark-approved-wordpress-plugin/postmark.php     2014-06-10 14:39:08.000000000 -0600
       @@ -286,8 +286,8 @@
   
            $response = pm_send_mail($postmark_headers, $email);
   
       -    if ($response !== true){
       -       return "Test Failed with Error ".$response['body'];
       +    if ($response === false){
       +       return "Test Failed with Error ".curl_error($curl);
            } else {
               return "Test Sent";
               }
       @@ -306,8 +306,8 @@
               if($response['response']['code'] == 200) {
                       return true;
               } else {
       -               return $response;
       +               return false;
               }
        }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Fatal Error’ is closed to new replies.

 * ![](https://ps.w.org/postmark-approved-wordpress-plugin/assets/icon.svg?rev=2721461)
 * [ActiveCampaign Postmark for Wordpress](https://wordpress.org/plugins/postmark-approved-wordpress-plugin/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/postmark-approved-wordpress-plugin/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/postmark-approved-wordpress-plugin/)
 * [Active Topics](https://wordpress.org/support/plugin/postmark-approved-wordpress-plugin/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/postmark-approved-wordpress-plugin/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/postmark-approved-wordpress-plugin/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [mhorbul](https://wordpress.org/support/users/mhorbul/)
 * Last activity: [10 years, 12 months ago](https://wordpress.org/support/topic/fatal-error-1394/#post-5432086)
 * Status: resolved