Exemple #1
0
<?php

if (isset($_GET['camp_id'])) {
    $camp = sola_nl_get_camp_details($_GET['camp_id']);
    $letter = sola_nl_get_letter($_GET['camp_id']);
    global $wpdb;
    global $sola_nl_camp_tbl;
    $wpdb->insert($sola_nl_camp_tbl, array('camp_id' => '', 'subject' => $camp->subject, 'theme_id' => $camp->theme_id, 'email' => $letter));
    $camp_id = $wpdb->insert_id;
} else {
    exit;
}
?>
<div class="wrap">    
   <div id="icon-edit" class="icon32 icon32-posts-post"><br></div>
   <h2><?php 
_e("Create a New Campaign", "sola");
?>
</h2>
   <div>
      <form action="" method="POST">
          <input type="hidden" value="<?php 
if ($camp_id) {
    echo $camp_id;
}
?>
" name="camp_id" />
         <table>
            <tr>
               <td width="250px">
                  <label><h3>Subject</h3></label>
Exemple #2
0
function sola_nl_build_automatic_content($camp_id, $mark_as_sent = false)
{
    global $post;
    $camp = sola_nl_get_camp_details($camp_id);
    //    var_dump($camp);
    $auto_options = maybe_unserialize($camp->automatic_data);
    //    var_dump($auto_options);
    //    ;
    $styles = maybe_unserialize($camp->styles);
    //    var_dump($styles);
    //    $ret_msg = " $camp_id";
    //    foreach ($auto_options as $val) {
    //        $ret_msg .= $key. " ".$val."<br />";
    //    }
    if (isset($auto_options['automatic_layout'])) {
        $layout = $auto_options['automatic_layout'];
    } else {
        $layout = 'layout-1';
    }
    if (isset($auto_options['automatic_options_posts'])) {
        $num_posts = intval($auto_options['automatic_options_posts']);
    } else {
        $num_posts = 1;
    }
    if (isset($auto_options['automatic_options_columns'])) {
        $posts_per_row = intval($auto_options['automatic_options_columns']);
    } else {
        $posts_per_row = 1;
    }
    if (isset($auto_options['automatic_image'])) {
        $post_image = $auto_options['automatic_image'];
    } else {
        $post_image = 1;
    }
    if (isset($auto_options['automatic_author'])) {
        $post_author = $auto_options['automatic_author'];
    } else {
        $post_author = 1;
    }
    if (isset($auto_options['automatic_title'])) {
        $post_title = $auto_options['automatic_title'];
    } else {
        $post_title = 1;
    }
    if (isset($auto_options['automatic_content'])) {
        $post_content = $auto_options['automatic_content'];
    } else {
        $post_content = 1;
    }
    if (isset($auto_options['automatic_readmore'])) {
        $post_readmore = $auto_options['automatic_readmore'];
    } else {
        $post_readmore = 1;
    }
    if (isset($auto_options['automatic_post_date'])) {
        $post_date = intval($auto_options['automatic_post_date']);
    } else {
        $post_date = 1;
    }
    if (isset($auto_options['automatic_post_length'])) {
        $post_length = intval($auto_options['automatic_post_length']);
    } else {
        $post_length = 255;
    }
    $automatic_scheduled_date = $auto_options['automatic_scheduled_date'];
    //    var_dump($post_length);
    //    exit();
    //    $post_date = 1;
    //    $post_length = 255;
    //        var_dump("POSTS: ".$num_posts);
    //        $num_posts = 3;
    //        var_dump("POSTS: ".$num_posts);
    //    $num_posts = 2;
    if ($num_posts == 0) {
        $num_posts = 1;
    }
    /*
      $args = array(
          'posts_per_page' => $num_posts,
          'orderby' => 'post_date',
          'order' => 'DESC',
          'post_type' => 'post',
    
          'meta_query' => array(
              array(
                'key' => 'sola_nl_auto_sent_'.$camp_id,
                'compare' => 'NOT EXISTS'
              )
            ),
          'date_query' => array( 
              array(
                  'after' => $automatic_scheduled_date
              )
          ),       
          
          
      );
      
      
      $recent_posts = query_posts($args);
    */
    $args = array('posts_per_page' => $num_posts, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post');
    //$recent_posts = wp_get_recent_posts( $args, ARRAY_A );
    //$recent_posts = wp_get_recent_posts( $args, ARRAY_A );
    $recent_posts = query_posts($args);
    if ($mark_as_sent) {
        $cnt = 0;
        foreach ($recent_posts as $post_data) {
            $key_value = get_post_meta($post_data->ID, 'sola_nl_auto_sent_' . $camp_id);
            if (isset($key_value[0])) {
                unset($recent_posts[$cnt]);
            } else {
                /* leave in */
            }
            unset($key_value);
            $cnt++;
        }
    }
    //    var_dump($recent_posts);
    $auto_content = "<table width='100%'>";
    //    $posts_per_row = 4;
    $rows_required = ceil($num_posts / $posts_per_row);
    //echo "rows required".$rows_required;
    $td_perc = 100 / $posts_per_row;
    $current_post = 0;
    for ($x = 0; $x < $rows_required; $x++) {
        //var_dump($x);
        if ($x == 0) {
            // first row
        }
        if ($x == $rows_required) {
            // last row
        }
        $auto_content .= "<tr>";
        for ($y = 0; $y < $posts_per_row; $y++) {
            if ($current_post > $num_posts) {
                //echo "blank ";
                // give blank TD
                $auto_content .= "<td width='{$td_perc}%'></td>";
            } else {
                //echo "not blank ";
                if (isset($recent_posts[$current_post]->ID) && $recent_posts[$current_post]->ID > 0) {
                    //echo "something ";
                    $auto_content .= "<td valign='top' width='{$td_perc}%'>" . sola_nl_build_specific_post($recent_posts[$current_post]->ID, $layout, $styles, $post_image, $post_title, $post_author, $post_content, $post_readmore, $post_date, $post_length) . "</td>";
                }
                $current_post++;
            }
            //echo "<br />";
        }
        $auto_content .= "</tr>";
    }
    foreach ($recent_posts as $ppost) {
        if ($ppost->ID > 0) {
            add_post_meta($ppost->ID, 'sola_nl_auto_sent_' . $camp_id, '1', true);
        }
    }
    $auto_content .= "</table>";
    //        var_dump($recent_posts);
    return $auto_content;
}
Exemple #3
0
<?php

$camp_id = $_GET['camp_id'];
$result = sola_nl_get_camp_details($camp_id);
$links_array = sola_nl_camp_links($camp_id);
$lists = sola_nl_get_camp_lists($camp_id);
global $sola_nl_camp_subs_tbl;
global $wpdb;
$sql = "SELECT COUNT(`id`) as `total` FROM `{$sola_nl_camp_subs_tbl}` WHERE `camp_id` = '{$camp_id}'";
$sdf = $wpdb->get_row($sql);
$total_subscribers = $sdf->total;
$sql = "SELECT COUNT(`id`) as `total` FROM `{$sola_nl_camp_subs_tbl}` WHERE `camp_id` = '{$camp_id}' AND `status` >= 1";
$sdf = $wpdb->get_row($sql);
$total_sent = $sdf->total;
$sent_perc = round($total_sent / $total_subscribers * 100, 1);
if (function_exists('sola_nl_register_pro_return_stats')) {
    //Return stats for current campaign
    $stats = sola_nl_register_pro_return_stats($camp_id);
    $total_opens = $stats['opens'];
    $total_sent = $stats['sent'];
    if ($total_opens != 0 && $total_sent != 0) {
        $open_rate = round($total_opens / $total_sent * 100, 2);
    } else {
        $open_rate = 0;
    }
} else {
    $stats = '';
}
?>
<style>
    
Exemple #4
0
function custom_auto_mail_send()
{
    global $wpdb;
    global $sola_nl_camp_tbl;
    global $sola_nl_subs_tbl;
    global $sola_global_campid;
    global $sola_global_subid;
    //    echo 'Running';
    /*
     * Check to see if there are any auto posts available
     */
    $sql = "SELECT * FROM {$sola_nl_camp_tbl} WHERE `type` = 2 AND `action` = 3";
    $results = $wpdb->get_results($sql);
    if ($results) {
        foreach ($results as $result) {
            $auto_camp_id = $result->camp_id;
            //            echo "<h1>$auto_camp_id</h1>";
            $auto_data = $result->automatic_data;
            $raw_auto_data = maybe_unserialize($auto_data);
            // if not immediate but automatic post, create new campaign
            if ($raw_auto_data['type'] != 5 && $raw_auto_data['action'] == 3) {
                //                    var_dump("type != 5 action = 3");
                $current_time = date('Y-m-d H:i:s', current_time('timestamp'));
                $scheduled_time = $raw_auto_data['automatic_scheduled_date'];
                if ($current_time >= $scheduled_time && $scheduled_time != '0000-00-00 00:00:00') {
                    echo 'Running Because Time Is Less Than Current';
                    $are_there_new_posts_to_email = sola_nl_check_if_new_posts_exist($auto_camp_id, $raw_auto_data['automatic_options_posts'], $raw_auto_data['automatic_scheduled_date']);
                    if ($are_there_new_posts_to_email != null) {
                        $auto_camp_id = $result->camp_id;
                        $auto_data = $result->automatic_data;
                        $raw_auto_data = maybe_unserialize($auto_data);
                        //                    var_dump($raw_auto_data);
                        $camp = sola_nl_get_camp_details($auto_camp_id);
                        $lists = sola_nl_get_camp_lists($auto_camp_id);
                        //                            var_dump($lists);
                        foreach ($lists as $list) {
                            $list_id = $list->list_id;
                            $new_lists[] = $list_id;
                            //                        var_dump($new_lists);
                        }
                        $type = 1;
                        /* insert it as a normal campaign */
                        $letter = sola_nl_get_letter($auto_camp_id);
                        //                    echo $letter;
                        //                    exit();
                        $inserted_data = sola_nl_build_automatic_content($auto_camp_id, true);
                        //                    echo $inserted_data;
                        //                    $sola_global_campid = $auto_camp_id;
                        //                            var_dump("CAMP ID ". $auto_camp_id);
                        //                    exit();
                        $table = preg_replace('/<table id="sola_nl_automatic_container"(.*?)<\\/table>/is', $inserted_data, $letter);
                        //                    $table = do_shortcode($table);
                        echo $table;
                        $subject = do_shortcode($camp->subject);
                        $wpdb->insert($sola_nl_camp_tbl, array('camp_id' => '', 'subject' => $subject, 'theme_id' => $camp->theme_id, 'email' => $table, 'styles' => $camp->styles, 'type' => $type));
                        $camp_id = $wpdb->insert_id;
                        //                            var_dump("NEW CAMP ID = ".$camp_id);
                        global $sola_global_campid;
                        $sola_global_campid = $camp_id;
                        //$working_table = do_shortcode($table);
                        //echo $working_table;
                        //                    echo 'Doing Update Below This';
                        //$wpdb->update($sola_nl_camp_tbl, array('email' => $working_table), array('camp_id' => $camp_id));
                        $checker = sola_nl_finish_camp(3, $current_time, $camp->sent_from, $camp->sent_from_name, $camp->reply_to, $camp->reply_to_name, $camp_id, $new_lists, $auto = true);
                        //                            print_r($new_lists);
                        var_dump('This will be the new campaign id ' . $camp_id);
                        //                    exit();
                        if (is_wp_error($checker)) {
                            sola_return_error($checker);
                        }
                        /* we need to have a check here to see if this works or not */
                        if (function_exists('sola_nl_add_subs_to_camp_pro')) {
                            sola_nl_add_subs_to_camp_pro($camp_id);
                        } else {
                            sola_nl_add_subs_to_camp($camp_id);
                        }
                    } else {
                        /* there are no new posts during this scheduled run */
                        var_dump("there are no new posts to send in this scheduled run");
                    }
                }
                /* set the next scheduled run */
                $the_current_time = current_time('timestamp');
                var_dump("current time: " . date("Y-m-d H:i:s", $the_current_time));
                $type = $raw_auto_data['type'];
                $day = $raw_auto_data['data']['day'];
                var_dump($day);
                $custom_time = $raw_auto_data['data']['time'];
                var_dump($custom_time);
                //                echo 'The time here';
                //                $the_current_time = strtotime('2014-10-08 08:30:00');
                if ($type == 1) {
                    //Daily
                    if (strtotime(date("Y-m-d", $the_current_time) . " " . $custom_time . ":00") > $the_current_time) {
                        var_dump("current time less than time. set it for today");
                        $time = date('Y-m-d H:i:s', strtotime(date("Y-m-d", $the_current_time) . " " . $custom_time . ":00"));
                    } else {
                        var_dump("current time greater than time, set it for next time");
                        $time = date('Y-m-d H:i:s', strtotime('+1 day ' . $custom_time . ':00', $the_current_time));
                    }
                } else {
                    if ($type == 2) {
                        //Weekly
                        if ($day == 1) {
                            $chosen_day = 'Monday';
                        } else {
                            if ($day == 2) {
                                $chosen_day = 'Tuesday';
                            } else {
                                if ($day == 3) {
                                    $chosen_day = 'Wednesday';
                                } else {
                                    if ($day == 4) {
                                        $chosen_day = 'Thursday';
                                    } else {
                                        if ($day == 5) {
                                            $chosen_day = 'Friday';
                                        } else {
                                            if ($day == 6) {
                                                $chosen_day = 'Saturday';
                                            } else {
                                                if ($day == 7) {
                                                    $chosen_day = 'Sunday';
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        $time = date('Y-m-d H:i:s', strtotime("+1 Week " . $chosen_day . ' ' . $custom_time . ':00', $the_current_time));
                    } else {
                        $time = date('Y-m-d H:i:s', current_time('timestamp'));
                    }
                }
                //                echo $time;
                $new_automatic_data = array('type' => $raw_auto_data['type'], 'action' => $raw_auto_data['action'], 'data' => array('day' => $raw_auto_data['data']['day'], 'time' => $raw_auto_data['data']['time'], 'daynum' => $raw_auto_data['data']['daynum'], 'timeafter' => $raw_auto_data['data']['timeafter'], 'timeqty' => $raw_auto_data['data']['timeqty'], 'role' => $raw_auto_data['data']['role']), 'automatic_layout' => $raw_auto_data['automatic_layout'], 'automatic_options_posts' => $raw_auto_data['automatic_options_posts'], 'automatic_options_columns' => $raw_auto_data['automatic_options_columns'], 'automatic_image' => $raw_auto_data['automatic_image'], 'automatic_author' => $raw_auto_data['automatic_author'], 'automatic_title' => $raw_auto_data['automatic_title'], 'automatic_content' => $raw_auto_data['automatic_content'], 'automatic_readmore' => $raw_auto_data['automatic_readmore'], 'automatic_scheduled_date' => $time, 'automatic_post_date' => $raw_auto_data['automatic_post_date'], 'automatic_post_length' => $raw_auto_data['automatic_post_length']);
                $serialized_auto_data = maybe_serialize($new_automatic_data);
                $wpdb->update($sola_nl_camp_tbl, array('automatic_data' => $serialized_auto_data), array('camp_id' => $auto_camp_id));
                var_dump("Next scheduled date set to " . $time);
            }
        }
    }
    /*
     * Check to see if there are any subscribers that need to be emailed.
     */
    $sql = "SELECT * FROM {$sola_nl_subs_tbl} WHERE `status` = 1 AND `sola_nl_mail_sent` = 0";
    $sub_results = $wpdb->get_results($sql);
    //    var_dump($sub_results);
    if ($sub_results) {
        foreach ($sub_results as $sub) {
            $sub_id = $sub->sub_id;
            $user_email = $sub->sub_email;
            if ($sub->sub_name == '') {
                $user_name = $sub->sub_email;
            } else {
                $user_name = $sub->sub_name;
            }
            $user_mail_sent = $sub->sola_nl_mail_sent;
            $user_mail_send_time = $sub->sola_nl_mail_sending_time;
            if ($user_mail_sent != '' && $user_mail_send_time != '' && $user_mail_send_time != '0000-00-00 00:00:00') {
                $current_time = date('Y-m-d H:i:s', current_time('timestamp'));
                $sql = "SELECT * FROM {$sola_nl_camp_tbl} WHERE `type` = 2 AND `action` = 4";
                $results = $wpdb->get_results($sql);
                //                var_dump($results);
                if ($results) {
                    foreach ($results as $result) {
                        if (isset($result->camp_id)) {
                            $camp_id = $result->camp_id;
                        } else {
                            $camp_id = '';
                        }
                        $sola_global_campid = $camp_id;
                        $sql = "SELECT * FROM {$sola_nl_subs_tbl} WHERE `sub_email` = '{$user_email}'";
                        $subscriber_details = $wpdb->get_row($sql);
                        $sub_id = $subscriber_details->sub_id;
                        $sola_global_subid = $sub_id;
                        if (isset($user_email)) {
                            $to = $user_email;
                        } else {
                            $to = '';
                        }
                        if (isset($result->subject)) {
                            $subject = stripslashes(do_shortcode($result->subject));
                        } else {
                            $subject = '';
                        }
                        if (isset($result->email)) {
                            $body_contents = stripslashes(do_shortcode(trim($result->email)));
                        } else {
                            $body_contents = '';
                        }
                        //                        var_dump($result->email);
                        //                        echo SITE_URL;
                        //                        echo $body_contents;
                        //                        exit();
                        $body = sola_nl_mail_body($body_contents, $camp_id, $camp_id);
                        if (isset($result->styles)) {
                            $styles = $result->styles;
                        } else {
                            $styles = '';
                        }
                    }
                    if ($current_time >= $user_mail_send_time && $user_mail_sent == 0) {
                        $mail_sent = sola_mail($camp_id, $to, $subject, $body);
                        if ($mail_sent) {
                            $wpdb->update($sola_nl_subs_tbl, array('sola_nl_mail_sent' => 1), array('sub_id' => $sub_id));
                        }
                    }
                }
            }
        }
    }
    /*
     * Check to see if there are any users that need to be emailed.
     */
    $args = array('meta_key' => '_sola_nl_mail_sent', 'meta_value' => '0');
    $users = get_users($args);
    foreach ($users as $user) {
        $user_id = $user->ID;
        $user_email = $user->data->user_email;
        $user_name = $user->data->display_name;
        $user_role = $user->roles[0];
        $sql = "SELECT * FROM {$sola_nl_camp_tbl} WHERE `type` = 2 AND `action` = 5";
        $results = $wpdb->get_results($sql);
        //        var_dump("USERS");
        //        var_dump($results);
        foreach ($results as $result) {
            $auto_camp_id = $result->camp_id;
            $auto_data = $result->automatic_data;
            $raw_auto_data = maybe_unserialize($auto_data);
            $role = intval($raw_auto_data['data']['role']);
            if ($role == 1 || $role == 2 && $user_role == 'administrator' || $role == 3 && $user_role == 'editor' || $role == 4 && $user_role == 'author' || $role == 5 && $user_role == 'contributor' || $role == 6 && $user_role == 'subscriber') {
                $user_mail_sent = get_user_meta($user_id, '_sola_nl_mail_sent', true);
                $user_mail_send_time = get_user_meta($user_id, '_sola_nl_mail_sending_time', true);
                if ($user_mail_sent != '' && $user_mail_send_time != '') {
                    $current_time = date('Y-m-d H:i:s', current_time('timestamp'));
                    $user_meta = get_user_meta($user_id);
                    $user_data = get_userdata($user_id);
                    $user_role = $user_data->roles[0];
                    $sql = "SELECT * FROM {$sola_nl_camp_tbl} WHERE `type` = 2 AND `action` = 5";
                    $results = $wpdb->get_results($sql);
                    if ($results) {
                        foreach ($results as $result) {
                            $camp_id = $result->camp_id;
                            //                            echo $camp_id;
                            //                            global $sola_global_campid;
                            $sola_global_campid = $camp_id;
                            $to = $user_email;
                            $subject = do_shortcode($result->subject);
                            $body_contents = stripslashes(do_shortcode(trim($result->email)));
                            //                            echo $body_contents;
                            $body = sola_nl_mail_body($body_contents, $user_id, $camp_id);
                            $styles = $result->styles;
                        }
                        if ($current_time >= $user_mail_send_time && $user_mail_sent == 0) {
                            $mail_sent = sola_mail($camp_id, $to, $subject, $body);
                            if ($mail_sent) {
                                update_user_meta($user_id, '_sola_nl_mail_sent', 1);
                            }
                        }
                    }
                }
            }
        }
    }
}
Exemple #5
0
function sola_nl_ajax_send($subscribers, $camp_id)
{
    $debug_start = (double) array_sum(explode(' ', microtime()));
    global $wpdb;
    global $sola_nl_camp_tbl;
    global $sola_nl_camp_subs_tbl;
    global $sola_nl_subs_tbl;
    global $sola_global_subid;
    global $sola_global_campid;
    if ($camp_id) {
        echo get_option("sola_currently_sending");
        if (!get_option("sola_currently_sending")) {
            if (get_option("sola_currently_sending") == "yes") {
                return "We are currently sending. Dont do anything";
            } else {
                update_option("sola_currently_sending", "yes");
            }
        } else {
            add_option("sola_currently_sending", "yes");
        }
        update_option("sola_currently_sending", "yes");
        $camp = sola_nl_get_camp_details($camp_id);
        if (isset($camp->reply_to)) {
            $reply = $camp->reply_to;
        }
        if (isset($camp->reply_to_name)) {
            $reply_name = stripslashes($camp->reply_to_name);
        }
        if (isset($camp->sent_from)) {
            $sent_from = $camp->sent_from;
        }
        if (isset($camp->sent_from_name)) {
            $sent_from_name = stripslashes($camp->sent_from_name);
        }
        if (empty($reply)) {
            $reply = get_option("sola_nl_reply_to");
        }
        if (empty($reply_name)) {
            $reply_name = get_option("sola_nl_reply_to_name");
        }
        if (empty($sent_from)) {
            $sent_from = get_option("sola_nl_sent_from");
        }
        if (empty($sent_from_name)) {
            $sent_from_name = get_option("sola_nl_sent_from_name");
        }
        // get option for either SMTP or normal WP MAil
        // split below based on above
        $saved_send_method = get_option("sola_nl_send_method");
        if ($saved_send_method == "1") {
            $headers[] = 'From: ' . $sent_from_name . '<' . $sent_from . '>';
            $headers[] = 'Content-type: text/html';
            $headers[] = 'Reply-To: ' . $reply_name . '<' . $reply . '>';
        } else {
            if ($saved_send_method >= "2") {
                $file = PLUGIN_URL . '/includes/phpmailer/PHPMailerAutoload.php';
                require_once $file;
                $mail = new PHPMailer();
                $mail->IsSMTP();
                $mail->SMTPAuth = true;
                $mail->SMTPKeepAlive = true;
                $port = get_option("sola_nl_port");
                $encryption = get_option("sola_nl_encryption");
                if ($encryption) {
                    $mail->SMTPSecure = $encryption;
                }
                $host = get_option("sola_nl_host");
                $mail->Host = $host;
                $mail->Username = get_option("sola_nl_username");
                $mail->Password = get_option("sola_nl_password");
                $mail->Port = $port;
                $mail->AddReplyTo($reply, $reply_name);
                $mail->SetFrom($sent_from, $sent_from_name);
                $mail->Subject = $camp->subject;
                $mail->SMTPDebug = 0;
            }
        }
        if ($subscribers) {
            foreach ($subscribers as $subscriber) {
                set_time_limit(600);
                $sub_id = $subscriber['sub_id'];
                $sub_email = $subscriber['sub_email'];
                echo $sub_email;
                $body = sola_nl_mail_body($camp->email, $sub_id, $camp->camp_id);
                $sola_global_subid = $sub_id;
                $sola_global_campid = $camp->camp_id;
                $body = do_shortcode($body);
                $body = sola_nl_replace_links($body, $sub_id, $camp->camp_id);
                /* ------ */
                //$check = sola_mail($camp_id ,$sub_email, $camp->subject, $body);
                if ($saved_send_method == "1") {
                    if (wp_mail($sub_email, $camp->subject, $body, $headers)) {
                        $check = true;
                    } else {
                        if (!$debug) {
                            $check = array('error' => 'Error sending mail to' . $sub_email);
                        } else {
                            $check = array('error' => "Failed to send email to {$sub_email}... " . $GLOBALS['phpmailer']->ErrorInfo);
                        }
                    }
                } else {
                    if ($saved_send_method >= "2") {
                        if (is_array($sub_email)) {
                            foreach ($sub_email as $address) {
                                $mail->AddAddress($address);
                            }
                        } else {
                            $mail->AddAddress($sub_email);
                        }
                        $mail->Body = $body;
                        $mail->IsHTML(true);
                        //echo "sending to $sub_email<br />";
                        if (!$mail->Send()) {
                            $check = array('error' => 'Error sending mail to ' . $sub_email);
                        } else {
                            $check = true;
                        }
                    }
                }
                if ($check === true) {
                    sola_update_camp_limit($camp_id);
                    $wpdb->update($sola_nl_camp_subs_tbl, array('status' => 1), array('camp_id' => $camp_id, 'sub_id' => $sub_id), array('%d'), array('%d', '%d'));
                    //echo "Email sent to $sub_email successfully <br />";
                } else {
                    sola_return_error(new WP_Error('sola_error', __('Failed to send email to subscriber'), 'Could not send email to ' . $sub_email));
                    //echo "<p>Failed to send to ".$sub_email."</p>";
                }
                $mail->clearAddresses();
                $mail->clearAttachments();
                $end = (double) array_sum(explode(' ', microtime()));
                echo "<br />processing time: " . sprintf("%.4f", $end - $debug_start) . " seconds<br />";
                //$check = sola_nl_send_mail_via_cron($camp_id,$sub_id,$sub_email);
                //if ( is_wp_error($check)) sola_return_error($check);
            }
        } else {
            /* do nothing, reached limit */
        }
        if ($saved_send_method >= "2") {
            $mail->smtpClose();
        }
        $end = (double) array_sum(explode(' ', microtime()));
        echo "<br />processing time: " . sprintf("%.4f", $end - $debug_start) . " seconds<br />";
        update_option("sola_currently_sending", "no");
        sola_nl_done_sending_camp($camp_id);
    } else {
        echo "<br />nothing to send at this time<br />";
    }
}