false, 'status' => 0, 'error' => 'engine_paused' ); } if ( defined( 'AIEO_EMAIL_HARD_DISABLE' ) && AIEO_EMAIL_HARD_DISABLE ) { return array( 'ok' => false, 'status' => 0, 'error' => 'hard_disabled' ); } $to = sanitize_email( (string) $to ); if ( '' === $to || ! is_email( $to ) ) { return array( 'ok' => false, 'status' => 0, 'error' => 'invalid_recipient' ); } $subject = trim( wp_strip_all_tags( (string) $subject ) ); if ( '' === $subject ) { return array( 'ok' => false, 'status' => 0, 'error' => 'empty_subject' ); } $headers = array( 'Content-Type: text/html; charset=UTF-8' ); if ( ! empty( $args['from'] ) ) { $headers[] = 'From: ' . $args['from']; } if ( ! empty( $args['reply_to'] ) ) { $headers[] = 'Reply-To: ' . $args['reply_to']; } if ( ! empty( $args['headers'] ) && is_array( $args['headers'] ) ) { $headers = array_merge( $headers, $args['headers'] ); } $as_html = static function () { return 'text/html'; }; add_filter( 'wp_mail_content_type', $as_html ); $ok = wp_mail( $to, $subject, (string) $html, $headers ); remove_filter( 'wp_mail_content_type', $as_html ); return array( 'ok' => (bool) $ok, 'status' => $ok ? 200 : 0, 'error' => $ok ? '' : 'wp_mail_failed', ); } }