format( 'm/d/Y g:i A' ); $form = GFAPI::get_form( $entry['form_id'] ); $form_title = $form['title']; $subject = "Email failed to send for form $form_title at $time"; $user = wp_get_current_user(); $user_id = $user->ID; $user_name = $user_id > 0 ? $user->display_name : 'Guest'; $user_email = $user_id > 0 ? $user->user_email : 'N/A'; $url = $entry['source_url']; $email_content = ''; $entry_link = '' . $entry['id'] . ''; foreach ( $email as $key => $value ) { if ( is_array( $value ) ) { $value = implode( ', ', $value ); } $email_content .= $key . ': ' . $value . PHP_EOL; } $message = "Time: $time" . PHP_EOL . "URL: $url" . PHP_EOL . "Form: $form_title" . PHP_EOL . "Entry: $entry_link" . PHP_EOL . "User: $user_name" . PHP_EOL . "User Email: $user_email" . PHP_EOL . 'Error: ' . $error->get_error_message() . PHP_EOL . 'Email content:' . PHP_EOL . $email_content; wp_mail( $to, $subject, $message ); }, 10, 3 );