function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
 {
     try {
         $sent = WPED()->connections->mail($to, $subject, $message, $headers, $attachments);
         if (is_wp_error($sent)) {
             return WPED()->connections->wp_mail($to, $subject, $message, $headers, $attachments);
         }
         return true;
     } catch (Exception $e) {
         return WPED()->connections->wp_mail($to, $subject, $message, $headers, $attachments);
     }
 }
 /**
  * Load settings page content
  * @return void
  */
 public function settings_page()
 {
     if (!WPED()->connections->is_setup()) {
         wped_set_option('enable_sending', false);
     }
     $button_text = esc_attr(__('Save Settings', 'wp-email-delivery'));
     // Build page HTML
     $html = '<div class="wrap" id="' . $this->parent->_token . '_settings">' . "\n";
     $html .= '<h2>' . __('WP Email Delivery', 'wp-email-delivery') . ' <small>v' . $this->parent->_version . '</small></h2>' . "\n";
     if (isset($this->parent->wp_mail_error)) {
         $html .= '</p>' . $this->parent->wp_mail_error . '</p>';
     }
     $tab = '';
     if (isset($_GET['tab']) && $_GET['tab']) {
         $tab .= $_GET['tab'];
     }
     // Show page tabs
     if (is_array($this->settings) && 1 < count($this->settings)) {
         $html .= '<h2 class="nav-tab-wrapper">' . "\n";
         $c = 0;
         foreach ($this->settings as $section => $data) {
             // Set tab class
             $class = 'nav-tab';
             if (!isset($_GET['tab'])) {
                 if (0 == $c) {
                     $class .= ' nav-tab-active';
                     $button_text = isset($data['custom_save']) ? $data['custom_save'] : esc_attr(__('Save Settings', 'wp-email-delivery'));
                 }
             } else {
                 if (isset($_GET['tab']) && $section == $_GET['tab']) {
                     $class .= ' nav-tab-active';
                     $button_text = isset($data['custom_save']) ? $data['custom_save'] : esc_attr(__('Save Settings', 'wp-email-delivery'));
                 }
             }
             // Set tab link
             $tab_link = add_query_arg(array('tab' => $section));
             if (isset($_GET['settings-updated'])) {
                 $tab_link = remove_query_arg('settings-updated', $tab_link);
             }
             // Output tab
             $html .= '<a href="' . $tab_link . '" class="' . esc_attr($class) . '">' . esc_html($data['title']) . '</a>' . "\n";
             ++$c;
         }
         $html .= '</h2>' . "\n";
     }
     $target = "options.php";
     if (wped_is_network_activated()) {
         $target = 'edit.php?action=' . $this->parent->_token . '_settings';
     }
     $html .= '<form method="post" action="' . $target . '" enctype="multipart/form-data">' . "\n";
     // Get settings fields
     ob_start();
     settings_fields($this->parent->_token . '_settings');
     do_settings_sections($this->parent->_token . '_settings');
     $html .= ob_get_clean();
     if ($button_text != 'none') {
         $html .= '<p class="submit">' . "\n";
         $html .= '<input type="hidden" name="tab" value="' . esc_attr($tab) . '" />' . "\n";
         $html .= '<input name="Submit" type="submit" class="button-primary" value="' . $button_text . '" />' . "\n";
         $html .= '</p>' . "\n";
     }
     $html .= '</form>' . "\n";
     if (!WPED()->connections->is_setup()) {
         $html .= "<div style='padding: 30px 40px; border: solid 1px #cdcdcd; background: #fff; margin-top: 5px;'><h2 style='margin-top: 0px; padding-top: 0px;'>Get WP Email Delivery for your site.</h2>";
         $html .= "<p>Try it for free with <strong>50 emails per month</strong>. Sign up at <a target='_blank' href='https://www.wpemaildelivery.com'>https://www.wpemaildelivery.com</a><br>Great for small sites and developers.</p>";
         $html .= '<p>Need more emails per month check out our monthly plans starting at <strong>$5.00 a month for 10,000 emails</strong>.<br>';
         $html .= 'We also have yearly plans starting at <strong>$18 per year for 500 monthly emails</strong>.</p>';
         $html .= "</div>";
     }
     $html .= '</div>' . "\n";
     echo $html;
     $this->templates();
 }