function save_email() { //$this->security_check(); $clean_post_id = SPNL()->validate->int($_POST['post_ID']); if ($clean_post_id > 0) { $post_update = array('ID' => $clean_post_id, 'post_content' => $_POST['content_area_one_edit']); update_post_meta($clean_post_id, '_sendpress_template', SPNL()->validate->int($_POST['template'])); update_post_meta($clean_post_id, '_sendpress_subject', sanitize_text_field($_POST['post_subject'])); update_post_meta($clean_post_id, '_header_content', sanitize_text_field($_POST['header_content_edit'])); update_post_meta($clean_post_id, '_footer_content', sanitize_text_field($_POST['footer_content_edit'])); // print_r($template); wp_update_post($post_update); if (isset($_POST['submit']) && $_POST['submit'] == 'save-next') { SendPress_Admin::redirect('Emails_Systememail', array('emailID' => SPNL()->validate->_int('emailID'))); } else { if (isset($_POST['submit']) && $_POST['submit'] == 'send-test') { $email = new stdClass(); $email->emailID = $clean_post_id; $email->subscriberID = 0; $email->listID = 0; $email->to_email = $_POST['test-email']; $d = SendPress_Manager::send_test_email($email); //print_r($d); SendPress_Admin::redirect('Emails_Systememail', array('emailID' => SPNL()->validate->_int('emailID'))); } else { SendPress_Admin::redirect('Emails_Systememail', array('emailID' => SPNL()->validate->_int('emailID'))); } } } }
function save_email() { //print_r($_POST['content-1']); //content-area-one-edit //$template = get_post(); //$_POST['post_type'] = 'sp_newsletters'; //$my_post = _wp_translate_postdata(true); //print_r($my_post); //$template['post_content'] = $my_post->content_area_one_edit; $post_update = array('ID' => $_POST['post_ID'], 'post_content' => $_POST['content_area_one_edit']); update_post_meta($_POST['post_ID'], '_sendpress_template', $_POST['template']); update_post_meta($_POST['post_ID'], '_sendpress_subject', $_POST['post_subject']); update_post_meta($_POST['post_ID'], '_header_content', $_POST['header_content_edit']); update_post_meta($_POST['post_ID'], '_footer_content', $_POST['footer_content_edit']); // print_r($template); wp_update_post($post_update); if (isset($_POST['submit']) && $_POST['submit'] == 'save-next') { SendPress_Admin::redirect('Emails_Send', array('emailID' => $_GET['emailID'])); } else { if (isset($_POST['submit']) && $_POST['submit'] == 'send-test') { $email = new stdClass(); $email->emailID = $_POST['post_ID']; $email->subscriberID = 0; $email->listID = 0; $email->to_email = $_POST['test-email']; $d = SendPress_Manager::send_test_email($email); //print_r($d); SendPress_Admin::redirect('Emails_Edit', array('emailID' => $_GET['emailID'])); } else { SendPress_Admin::redirect('Emails_Edit', array('emailID' => $_GET['emailID'])); } } }
static function external($template_id, $email_id, $subscriber_id, $e) { $link = SendPress_Manager::public_url('unsubscribe'); $email_key = str_replace('=', '', base64_encode($email_id)); //Uses a know url 4/20 return add_query_arg(array('sid' => '{sp-subscriber-id-encoded}', 'rid' => $email_key), $link); }
function send_test_email() { $options = array(); $options['testemail'] = $_POST['testemail']; SendPress_Option::set($options); SendPress_Manager::send_test(); // SendPress_Admin::redirect('Settings_Account'); // $this->send_test(); // $this->redirect(); }
static function external($template_id, $email_id, $subscriber_id, $e) { /* $open_info = array( "id"=>$email_id, "view"=>"email" ); $code = SendPress_Data::encrypt( $open_info ); $xlink = SendPress_Manager::public_url($code); */ $link = SendPress_Manager::public_url('email'); $email_key = str_replace('=', '', base64_encode($email_id)); return add_query_arg(array('sid' => '{sp-subscriber-id-encoded}', 'eid' => $email_key), $link); return $xlink; }
static function send_mail_cron() { //@ini_set('max_execution_time',0); global $wpdb; $count = SendPress_Option::get('emails-per-hour'); $count = SendPress_Option::get('wpcron-per-call', 25); $email_count = 0; $attempts = 0; if (SendPress_Manager::limit_reached($count)) { return; } SendPress_Email_Cache::build_cache(); for ($i = 0; $i < $count; $i++) { $email = SendPress_Data::get_single_email_from_queue(); if ($email != null) { $attempts++; SendPress_Data::queue_email_process($email->id); $result = SendPress_Manager::send_email_from_queue($email); $email_count++; if ($result) { if ($result === true) { $wpdb->update(SendPress_Data::queue_table(), array('success' => 1, 'inprocess' => 3), array('id' => $email->id)); //( $sid, $rid, $lid=null, $uid=null, $ip=null, $device_type=null, $device=null, $type='confirm' ) //$wpdb->update( SendPress_Data::queue_table() , array('success'=>1,'inprocess'=>3 ) , array('id'=> $email->id )); //$wpdb->insert(SendPress_Data::subscriber_tracker_table() , array('subscriberID'=>$email->subscriberID,'emailID'=>$email->emailID,'sent_at' => get_gmt_from_date( date('Y-m-d H:i:s') )) ); SPNL()->db->subscribers_tracker->add(array('subscriber_id' => intval($email->subscriberID), 'email_id' => intval($email->emailID))); SendPress_Data::add_subscriber_event($email->subscriberID, $email->emailID, $email->listID, null, null, null, null, 'send'); } else { $wpdb->update(SendPress_Data::queue_table(), array('success' => 2, 'inprocess' => 3), array('id' => $email->id)); SendPress_Data::add_subscriber_event($email->subscriberID, $email->emailID, $email->listID, null, null, null, null, 'bounce'); SendPress_Data::bounce_subscriber_by_id($email->subscriberID); } //$wpdb->insert( $this->subscriber_open_table(), $senddata); $count++; //SendPress_Data::update_report_sent_count( $email->emailID ); } else { $wpdb->update(SendPress_Data::queue_table(), array('attempts' => $email->attempts + 1, 'inprocess' => 0, 'last_attempt' => date('Y-m-d H:i:s')), array('id' => $email->id)); } } else { //We ran out of emails to process. break; } set_time_limit(30); } return; }
static function external($template_id, $email_id, $subscriber_id, $e) { //maybe saved link? $link_data = array("id" => $subscriber_id, "view" => 'manage'); $code = SendPress_Data::encrypt($link_data); $link = SendPress_Manager::public_url($code); if (SendPress_Option::get('manage-page') == 'custom') { $page = SendPress_Option::get('manage-page-id'); if ($page != false) { $plink = get_permalink($page); if ($plink != "") { $link = $plink . '?spms=' . $code; } } } return $link; }
function prerender() { $r = $_GET['rid']; $s = $_GET['sid']; $r = (int) base64_decode($r); $s = (int) base64_decode($s); if (is_numeric($r)) { $lists = get_post_meta($r, '_send_lists', true); $lists = explode(",", $lists); foreach ($lists as $list) { SendPress_Data::unsubscribe_from_list($s, $r, $list); } } $link_data = array("id" => $s, "report" => $r, "urlID" => '0', "view" => "manage", "listID" => "0", "action" => ""); $code = SendPress_Data::encrypt($link_data); $link = SendPress_Manager::public_url($code); $this->redirect($link); exit; }
function save_email() { //$this->security_check(); $post_id = SPNL()->validate->_int('post_ID'); if ($post_id > 0) { $html = SPNL()->validate->_html('content_area_one_edit'); //SendPress_Error::Log($html); $post_update = array('ID' => $post_id, 'post_content' => $html); update_post_meta($post_id, '_sendpress_template', SPNL()->validate->_int('template')); update_post_meta($post_id, '_sendpress_subject', sanitize_text_field(SPNL()->validate->_string('post_subject'))); if (SPNL()->validate->_isset('header_content_edit')) { update_post_meta($post_id, '_header_content', SPNL()->validate->_html('header_content_edit')); } if (SPNL()->validate->_isset('footer_content_edit')) { update_post_meta($post_id, '_footer_content', SPNL()->validate->_html('footer_content_edit')); } // print_r($template); remove_filter('content_save_pre', 'wp_filter_post_kses'); remove_filter('content_filtered_save_pre', 'wp_filter_post_kses'); wp_update_post($post_update); add_filter('content_save_pre', 'wp_filter_post_kses'); add_filter('content_filtered_save_pre', 'wp_filter_post_kses'); } if (SPNL()->validate->_string('submit') == 'save-next') { SendPress_Admin::redirect('Emails_Send', array('emailID' => SPNL()->validate->_int('emailID'))); } else { if (SPNL()->validate->_string('submit') == 'send-test') { $email = new stdClass(); $email->emailID = SPNL()->validate->_int('post_ID'); $email->subscriberID = 0; $email->listID = 0; $email->to_email = SPNL()->validate->_email('test-email'); $d = SendPress_Manager::send_test_email($email); //print_r($d); SendPress_Admin::redirect('Emails_Edit', array('emailID' => SPNL()->validate->_int('emailID'))); } else { SendPress_Admin::redirect('Emails_Edit', array('emailID' => SPNL()->validate->_int('emailID'))); } } }
function auto_cron() { // make sure we're in wp-cron.php if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-cron.php')) { // make sure a secret string is provided in the ur if (isset($_GET['action']) && $_GET['action'] == 'sendpress') { $time_start = microtime(true); $count = SendPress_Data::emails_in_queue(); $bg = 0; if ($count > 0) { SendPress_Queue::send_mail(); $count = SendPress_Data::emails_in_queue(); } else { SPNL()->log->prune_logs(); SendPress_Data::clean_queue_table(); //SendPress_Logging::prune_logs(); $bg = 1; } $attempted_count = SendPress_Option::get('autocron-per-call', 25); $pro = 0; if (defined('SENDPRESS_PRO_VERSION')) { $pro = SENDPRESS_PRO_VERSION; } $stuck = SendPress_Data::emails_stuck_in_queue(); $limit = SendPress_Manager::limit_reached(); $emails_per_day = SendPress_Option::get('emails-per-day'); $emails_per_hour = SendPress_Option::get('emails-per-hour'); $hourly_emails = SendPress_Data::emails_sent_in_queue("hour"); $emails_so_far = SendPress_Data::emails_sent_in_queue("day"); $limits = array('autocron' => $attempted_count, 'dl' => $emails_per_day, 'hl' => $emails_per_hour, 'ds' => $emails_so_far, 'hs' => $hourly_emails); $time_end = microtime(true); $time = $time_end - $time_start; echo json_encode(array("background" => $bg, "queue" => $count, "stuck" => $stuck, "version" => SENDPRESS_VERSION, "pro" => $pro, "limit" => $limit, 'info' => $limits, 'time' => number_format($time, 3))); die; } } }
function render_html($post_id = false, $render = true, $inline = false, $no_links = false, $custom_html = false) { global $post; remove_filter('the_content', 'sharing_display', 19); remove_filter('the_excerpt', 'sharing_display', 19); $saved = false; if ($post_id !== false) { $post = get_post($post_id); $saved = $post; } $saved = $post; if (!isset($post)) { //echo __('Sorry we could not find your email.','sendpress'); return; } //$selected_template = $this->get_template( $post_id ); //$template_list = $this->info(); $post_template = get_post_meta($post->ID, '_sendpress_template', true); if ($post_template != '' && is_numeric($post_template) && $post_template > 0) { $HtmlCode = SendPress_Email_Render_Engine::render_template($post_template, $post_id, $custom_html); } else { $old = get_post_meta($post->ID, '_sendpress_system', true); if ($old == 'old') { $HtmlCode = file_get_contents(SENDPRESS_PATH . '/templates/original.html'); } else { $HtmlCode = file_get_contents(SENDPRESS_PATH . '/templates/simple.html'); } } if ($HtmlCode != false) { /* ob_start(); require_once( $template_list[$selected_template]['file'] ); $HtmlCode= ob_get_clean(); */ $HtmlCode = do_shortcode($HtmlCode); add_filter('the_content', 'do_shortcode', 11); if ($custom_html == false) { $content = $post->post_content; } else { $content = $custom_html; } $content = apply_filters('the_content', $content); //print_r($post->post_content); $content = str_replace(']]>', ']]>', $content); //$content = do_shortcode( $content ); $HtmlCode = str_replace("*|SP:CONTENT|*", $content, $HtmlCode); $post = $saved; $HtmlCode = str_replace("*|SP:SUBJECT|*", $post->post_title, $HtmlCode); $body_bg = get_post_meta($post->ID, 'body_bg', true); $body_text = get_post_meta($post->ID, 'body_text', true); $body_link = get_post_meta($post->ID, 'body_link', true); $header_bg = get_post_meta($post->ID, 'header_bg', true); $active_header = get_post_meta($post->ID, 'active_header', true); $upload_image = get_post_meta($post->ID, 'upload_image', true); $header_text_color = get_post_meta($post->ID, 'header_text_color', true); $header_text = get_post_meta($post->ID, 'header_text', true); //needs adding to the template $header_link = get_post_meta($post->ID, 'header_link', true); //needs adding to the template $sub_header_text = get_post_meta($post->ID, 'sub_header_text', true); //needs adding to the template $image_header_url = get_post_meta($post->ID, 'image_header_url', true); //needs adding to the template $content_bg = get_post_meta($post->ID, 'content_bg', true); $content_text = get_post_meta($post->ID, 'content_text', true); $content_link = get_post_meta($post->ID, 'sp_content_link_color', true); $content_border = get_post_meta($post->ID, 'content_border', true); $header_link_open = ''; $header_link_close = ''; if ($active_header == 'image') { if (!empty($image_header_url)) { $header_link_open = "<a style='color:" . $header_text_color . "' href='" . $image_header_url . "'>"; $header_link_close = "</a>"; } $headercontent = $header_link_open . "<img style='display:block;' src='" . $upload_image . "' border='0' />" . $header_link_close; $HtmlCode = str_replace("*|SP:HEADERCONTENT|*", $headercontent, $HtmlCode); } else { if (!empty($header_link)) { $header_link_open = "<a style='color:" . $header_text_color . "' href='" . $header_link . "'>"; $header_link_close = "</a>"; } $headercontent = "<div style='padding: 10px; text-align:center;'><h1 style='text-align:center; color: " . $header_text_color . " !important;'>" . $header_link_open . $header_text . $header_link_close . "</h1>" . $sub_header_text . "</div>"; $HtmlCode = str_replace("*|SP:HEADERCONTENT|*", $headercontent, $HtmlCode); } $HtmlCode = str_replace("*|SP:HEADERBG|*", $header_bg, $HtmlCode); $HtmlCode = str_replace("*|SP:HEADERTEXT|*", $header_text_color, $HtmlCode); $HtmlCode = str_replace("*|SP:BODYBG|*", $body_bg, $HtmlCode); $HtmlCode = str_replace("*|SP:BODYTEXT|*", $body_text, $HtmlCode); $HtmlCode = str_replace("*|SP:BODYLINK|*", $body_link, $HtmlCode); $HtmlCode = str_replace("*|SP:CONTENTBG|*", $content_bg, $HtmlCode); $HtmlCode = str_replace("*|SP:CONTENTTEXT|*", $content_text, $HtmlCode); $HtmlCode = str_replace("*|SP:CONTENTLINK|*", $content_link, $HtmlCode); $HtmlCode = str_replace("*|SP:CONTENTBORDER|*", $content_border, $HtmlCode); $HtmlCode = $this->tag_replace($HtmlCode); // Date processing $canspam = wpautop(SendPress_Option::get('canspam')); $HtmlCode = str_replace("*|SP:CANSPAM|*", $canspam, $HtmlCode); $social = ''; if ($twit = SendPress_Option::get('twitter')) { $social .= "<a href='{$twit}' style='color: {$body_link};'>Twitter</a>"; } if ($fb = SendPress_Option::get('facebook')) { if ($social != '') { $social .= " | "; } $social .= "<a href='{$fb}' style='color: {$body_link};'>Facebook</a>"; } if ($ld = SendPress_Option::get('linkedin')) { if ($social != '') { $social .= " | "; } $social .= "<a href='{$ld}' style='color: {$body_link};'>LinkedIn</a>"; } $social = SendPress_Data::build_social($body_link); $HtmlCode = str_replace("*|SP:SOCIAL|*", $social, $HtmlCode); /* $dom = new DomDocument(); $dom->strictErrorChecking = false; @$dom->loadHtml($HtmlCode); $iTags = $dom->getElementsByTagName('img'); foreach ($iTags as $iElement) { $class = $iElement->getAttribute('class'); } $body_html = $dom->saveHtml(); */ /* $simplecss = file_get_contents(SENDPRESS_PATH.'/templates/simple.css'); // create instance $cssToInlineStyles = new CSSToInlineStyles($HtmlCode, $simplecss); // grab the processed HTML $HtmlCode = $cssToInlineStyles->convert(); */ $display_correct = __("Is this email not displaying correctly?", "sendpress"); $view = __("View it in your browser", "sendpress"); $start_text = __("Not interested anymore?", "sendpress"); $unsubscribe = __("Unsubscribe", "sendpress"); $instantly = __("Instantly", "sendpress"); $manage = __("Manage Subscription", "sendpress"); if ($render) { //RENDER IN BROWSER if ($inline) { $link = get_permalink($post->ID); $browser = $display_correct . ' <a style="color: ' . $body_link . ';" href="' . $link . '">' . $view . '</a>.'; $HtmlCode = str_replace("*|SP:BROWSER|*", $browser, $HtmlCode); $remove_me = ' <a href="#" style="color: ' . $body_link . ';" >' . $unsubscribe . '</a> | '; $manage = ' <a href="#" style="color: ' . $body_link . ';" >' . $manage . '</a> '; $HtmlCode = str_replace("*|SP:MANAGE|*", $manage, $HtmlCode); $HtmlCode = str_replace("*|SP:UNSUBSCRIBE|*", $remove_me, $HtmlCode); } else { $HtmlCode = str_replace("*|SP:BROWSER|*", '', $HtmlCode); $HtmlCode = str_replace("*|SP:UNSUBSCRIBE|*", '', $HtmlCode); $HtmlCode = str_replace("*|SP:MANAGE|*", '', $HtmlCode); $HtmlCode = str_replace("*|ID|*", '', $HtmlCode); $HtmlCode = str_replace("*|FNAME|*", '', $HtmlCode); $HtmlCode = str_replace("*|LNAME|*", '', $HtmlCode); $HtmlCode = str_replace("*|EMAIL|*", '', $HtmlCode); } echo $HtmlCode; } else { //PREP FOR SENDING if ($no_links == false) { $link = get_permalink($post->ID); $open_info = array("id" => $post->ID, "view" => "email"); $code = SendPress_Data::encrypt($open_info); $xlink = SendPress_Manager::public_url($code); $browser = $display_correct . ' <a style="color: ' . $body_link . ';" href="' . $xlink . '">' . $view . '</a>.'; $HtmlCode = str_replace("*|SP:BROWSER|*", $browser, $HtmlCode); } else { $HtmlCode = str_replace("*|SP:BROWSER|*", '', $HtmlCode); $HtmlCode = str_replace("*|SP:UNSUBSCRIBE|*", '', $HtmlCode); $HtmlCode = str_replace("*|SP:MANAGE|*", '', $HtmlCode); } return $HtmlCode; } } else { //echo __('Sorry we could not find your email template.','sendpress'); return; } }
static function auto_cron() { // make sure we're in wp-cron.php if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-cron.php')) { // make sure a secret string is provided in the ur if (isset($_GET['action']) && $_GET['action'] == 'sendpress') { //* Use cache static $cron_bg_run = null; static $cron_bg_run_weekly = null; $time_start = microtime(true); $count = SendPress_Data::emails_in_queue(); $bg = 0; $bg_weekly = 0; $error = ''; try { if ($count > 0) { SendPress_Queue::send_mail(); $count = SendPress_Data::emails_in_queue(); } else { //* If cache is empty, pull transient if (!$cron_bg_run) { $cron_bg_run = get_transient('spnl-background-daily'); } //* If transient has expired, do a fresh update check if (!$cron_bg_run) { //* If cache is empty, pull transient if (!$cron_bg_run_weekly) { $cron_bg_run_weekly = get_transient('spnl-background-weekly'); } //* If transient has expired, do a fresh update check if (!$cron_bg_run_weekly) { SPNL()->log->prune_logs(); SendPress_Data::clean_queue_table(); SendPress_DB_Tables::repair_tables(); $cron_bg_run_weekly = array('runtime' => date("F j, Y, g:i a")); set_transient('spnl-background-weekly', $cron_bg_run_weekly, 60 * 60 * 24 * 7); $bg_weekly = 1; } //SendPress_Logging::prune_logs(); $bg = 1; $cron_bg_run = array('runtime' => date("F j, Y, g:i a")); set_transient('spnl-background-daily', $cron_bg_run, 60 * 60 * 24); } } } catch (Exception $e) { $error = $e->getMessage(); SPNL()->log->add('Autocron', $error, 0, 'error'); } $attempted_count = SendPress_Option::get('autocron-per-call', 25); $pro = 0; if (defined('SENDPRESS_PRO_VERSION')) { $pro = SENDPRESS_PRO_VERSION; } $stuck = SendPress_Data::emails_stuck_in_queue(); $limit = SendPress_Manager::limit_reached(); $emails_per_day = SendPress_Option::get('emails-per-day'); $emails_per_hour = SendPress_Option::get('emails-per-hour'); $hourly_emails = SendPress_Data::emails_sent_in_queue("hour"); $emails_so_far = SendPress_Data::emails_sent_in_queue("day"); $limits = array('autocron' => $attempted_count, 'dl' => $emails_per_day, 'hl' => $emails_per_hour, 'ds' => $emails_so_far, 'hs' => $hourly_emails); $time_end = microtime(true); $time = $time_end - $time_start; echo json_encode(array("error" => $error, "background" => $bg, "weekly" => $bg_weekly, "queue" => $count, "stuck" => $stuck, "version" => SENDPRESS_VERSION, "pro" => $pro, "limit" => $limit, 'info' => $limits, 'time' => number_format($time, 3))); die; } } }
static function subscribe_user($listid, $email, $first, $last, $status = 2, $custom = array()) { $success = false; $subscriberID = SendPress_Data::add_subscriber(array('firstname' => $first, 'lastname' => $last, 'email' => $email)); //SendPress_Error::log($subscriberID); if (false === $subscriberID) { return false; } $args = array('post_type' => 'sendpress_list', 'numberposts' => -1, 'offset' => 0, 'orderby' => 'post_title', 'order' => 'DESC'); $lists = get_posts($args); $listids = explode(',', $listid); $already_subscribed = false; if ($status == 2 && SendPress_Option::is_double_optin()) { $inlists = SendPress_Data::get_active_list_ids_for_subscriber($subscriberID); //SendPress_Error::log($inlists); if ($inlists) { $already_subscribed = true; } else { $status = 1; SendPress_Manager::send_optin($subscriberID, $listids, $lists); } } foreach ($lists as $list) { if (in_array($list->ID, $listids)) { $current_status = SendPress_Data::get_subscriber_list_status($list->ID, $subscriberID); if (empty($current_status) || isset($current_status->status) && $current_status->status < 2) { $success = SendPress_Data::update_subscriber_status($list->ID, $subscriberID, $status); } else { $success = true; } foreach ($custom as $key => $value) { SendPress_Data::update_subscriber_meta($subscriberID, $key, $value, $list->ID); } } } if ($success == false) { return false; } return array('success' => $success, 'already' => $already_subscribed); }
function html($sp) { global $post_ID, $post; $view = isset($_GET['view']) ? $_GET['view'] : ''; $list = ''; if (isset($_GET['emailID'])) { $emailID = $_GET['emailID']; $post = get_post($_GET['emailID']); $post_ID = $post->ID; } ?> <form method="POST" name="post" id="post"> <?php $info = SendPress_Option::get('current_send_' . $post->ID); $subject = SendPress_Option::get('current_send_subject_' . $post->ID, true); ?> <div id="styler-menu"> <div style="float:right;" class="btn-group"> <a class="btn btn-primary btn-large " id="confirm-send" href="#"><i class="icon-white icon-thumbs-up"></i> <?php _e('Confirm Send', 'sendpress'); ?> </a> </div> </div> <div id="sp-cancel-btn" style="float:right; "> <a class="btn btn-default" href="<?php echo '?page=' . $_GET['page'] . '&view=send&emailID=' . $_GET['emailID']; ?> "><?php _e('Cancel Send', 'sendpress'); ?> </a> </div> <h2><?php _e('Confirm Send', 'sendpress'); ?> </h2> <br> <input type="hidden" id="user-id" name="user_ID" value="<?php //echo $current_user->ID; ?> " /> <input type="hidden" id="post_ID" name="post_ID" value="<?php echo $post->ID; ?> " /> <div class="boxer"> <div class="boxer-inner"> <?php $this->panel_start('<span class="glyphicon glyphicon-inbox"></span> ' . __('Subject', 'sendpress')); ?> <input type="text" class="form-control" value="<?php echo stripslashes(esc_attr(htmlspecialchars($subject))); ?> " disabled /> <?php $this->panel_end(); ?> <div class="leftcol"> <?php $this->panel_start('<span class="glyphicon glyphicon-calendar"></span> ' . __('Date & Time', 'sendpress')); if ($info['send_at'] == '0000-00-00 00:00:00') { echo "Your email will start sending right away!"; } else { echo "Your email will start sending on " . date('Y/m/d', strtotime($info['send_at'])) . " at " . date('h:i A', strtotime($info['send_at'])); } $this->panel_end(); $this->panel_start('<span class="glyphicon glyphicon-list"></span> ' . __('Lists', 'sendpress')); ?> <?php if (!empty($info['listIDS'])) { foreach ($info['listIDS'] as $list_id) { $list = $sp->get_list_details($list_id); echo $list->post_title . " <small>(" . SendPress_Data::get_count_subscribers($list_id) . ")</small><br>"; } } else { _e('No Lists Selected', 'sendpress'); echo "<br>"; } $this->panel_end(); $this->panel_start('<span class="glyphicon glyphicon-tag"></span> ' . __('Mark as Test', 'sendpress')); $sel = ''; if (get_post_meta($post_ID, 'istest', true) == true) { $sel = 'checked'; } echo "<input {$sel} name='test_report' type='checkbox' id='test_report' value='1' disabled> Test<br>"; echo "<small class='text-muted'>" . __('This puts the report into the Test tab on the Reports screen', 'sendpress') . ".</small>"; $this->panel_end(); ?> </div> <div style="margin-left: 250px;"> <div class="widerightcol"> <?php $link = get_permalink($post->ID); $sep = strstr($link, '?') ? '&' : '?'; $link = $link . $sep . 'inline=true'; $open_info = array("id" => $post->ID, "view" => "email"); $code = SendPress_Data::encrypt($open_info); $url = SendPress_Manager::public_url($code); $sep = strstr($url, '?') ? '&' : '?'; $link = $url . $sep . 'inline=true'; ?> <iframe src="<?php echo $link; ?> " width="100%" height="600px"></iframe> <small><?php _e('Displaying a 404? Please try saving your permalinks', 'sendpress'); ?> <a href="<?php echo admin_url('options-permalink.php'); ?> "><?php _e('here', 'sendpress'); ?> </a>.</small> </div> <?php wp_nonce_field($sp->_nonce_value); ?> <br><br> </div> </div> <br class="clear" /> </div> </form> <?php }
function save() { $saveid = SPNL()->validate->int($_POST['post_ID']); $bodybg = SPNL()->validate->hex($_POST['body_bg']); $bodytext = SPNL()->validate->hex($_POST['body_text']); $bodylink = SPNL()->validate->hex($_POST['body_link']); $contentbg = SPNL()->validate->hex($_POST['content_bg']); $contenttext = SPNL()->validate->hex($_POST['content_text']); $contentlink = SPNL()->validate->hex($_POST['sp_content_link_color']); $contentborder = SPNL()->validate->hex($_POST['content_border']); $upload_image = $_POST['upload_image']; $headerbg = SPNL()->validate->hex($_POST['header_bg']); $headertextcolor = SPNL()->validate->hex($_POST['header_text_color']); $headertext = sanitize_text_field($_POST['header_text']); $headerlink = esc_url_raw($_POST['header_link']); $imageheaderurl = esc_url_raw($_POST['image_header_url']); $subheadertext = sanitize_text_field($_POST['sub_header_text']); $activeHeader = $_POST['active_header']; $_POST['post_type'] = 'sp_newsletters'; // Update post 37 $my_post = _wp_translate_postdata(true); /* $my_post['ID'] = $_POST['post_ID']; $my_post['post_content'] = $_POST['content']; $my_post['post_title'] = $_POST['post_title']; */ /* $str = $my_post['post_content']; $DOM = new DOMDocument; $DOM->loadHTML($str); //get all H1 $aTags = $DOM->getElementsByTagName('a'); foreach ($aTags as $aElement) { $style = $aElement->getAttribute('style'); if($style == ""){ $aElement->setAttribute('style', 'color: '. $contentlink); } } $body_html = $DOM->saveHtml(); $my_post['post_content'] = $body_html; */ $my_post['post_status'] = 'publish'; // Update the post into the database wp_update_post($my_post); update_post_meta($my_post['ID'], '_sendpress_subject', sanitize_text_field($_POST['post_subject'])); update_post_meta($my_post['ID'], '_sendpress_template', SPNL()->validate->int($_POST['template'])); update_post_meta($my_post['ID'], '_sendpress_status', 'private'); SendPress_Email::set_default_style($my_post['ID']); //clear the cached file. delete_transient('sendpress_email_html_' . $my_post['ID']); update_post_meta($saveid, 'body_bg', $bodybg); update_post_meta($saveid, 'body_text', $bodytext); update_post_meta($saveid, 'body_link', $bodylink); update_post_meta($saveid, 'content_bg', $contentbg); update_post_meta($saveid, 'content_text', $contenttext); update_post_meta($saveid, 'sp_content_link_color', $contentlink); update_post_meta($saveid, 'content_border', $contentborder); update_post_meta($saveid, 'upload_image', $upload_image); update_post_meta($saveid, 'header_bg', $headerbg); update_post_meta($saveid, 'header_text_color', $headertextcolor); update_post_meta($saveid, 'header_text', $headertext); update_post_meta($saveid, 'header_link', $headerlink); update_post_meta($saveid, 'image_header_url', $imageheaderurl); update_post_meta($saveid, 'sub_header_text', $subheadertext); update_post_meta($saveid, 'active_header', $activeHeader); if (isset($_POST['submit']) && $_POST['submit'] == 'save-next') { SendPress_Admin::redirect('Emails_Send', array('emailID' => SPNL()->validate->int($_GET['emailID']))); } else { if (isset($_POST['submit']) && $_POST['submit'] == 'send-test') { $email = new stdClass(); $email->emailID = $my_post['ID']; $email->subscriberID = 0; $email->listID = 0; $email->to_email = $_POST['test-email']; $d = SendPress_Manager::send_test_email($email); //print_r($d); SendPress_Admin::redirect('Emails_Style', array('emailID' => SPNL()->validate->int($_GET['emailID']))); } else { SendPress_Admin::redirect('Emails_Style', array('emailID' => SPNL()->validate->int($_GET['emailID']))); } } }
function send_test() { _deprecated_function(__FUNCTION__, '0.8.9', 'SendPress_Manager::send_test()'); SendPress_Manager::send_test(); }
function reset_counters() { //$this->security_check(); SendPress_Manager::reset_counters(); SendPress_Admin::redirect('Queue'); }
private static function manage_sub_prerender() { $info = self::data(); if (isset($info->action) && $info->action == 'unsubscribe') { SendPress_Data::unsubscribe_from_list($info->id, $info->report, $info->listID); $link_data = array("id" => $info->id, "report" => $info->report, "urlID" => '0', "view" => "manage", "listID" => $info->listID, "action" => ""); $code = SendPress_Data::encrypt($link_data); $link = SendPress_Manager::public_url($code); //$this->redirect( $link ); //exit; } }
function html() { $post_template = $this->id(); global $wpdb; //$email = $this->email(); // Get any existing copy of our transient data if (SendPress_Email_Cache::get($this->id()) != null) { $body_html = SendPress_Email_Cache::get($this->id()); $post_template = get_post_meta($this->id(), '_sendpress_template', true); $body_html = spnl_do_email_tags($body_html, $post_template, $this->id(), $this->subscriber_id(), true); } else { if (false === ($body_html = get_transient('sendpress_report_body_html_' . $this->id())) || $this->purge() == true) { // It wasn't there, so regenerate the data and save the transient if (!$this->post_info) { $this->post_info = get_post($this->id()); } if ($this->cache() !== false) { $body_html = $this->cache(); } else { $body_html = SendPress_Template::get_instance()->render($this->id(), false, false, $this->remove_links()); $this->cache($body_html); } set_transient('sendpress_report_body_html_' . $this->id(), $body_html, 60 * 60 * 2); } } $subscriber = SendPress_Data::get_subscriber($this->subscriber_id()); if (!is_null($subscriber)) { $body_html = str_replace("*|FNAME|*", $subscriber->firstname, $body_html); $body_html = str_replace("*|LNAME|*", $subscriber->lastname, $body_html); $body_html = str_replace("*|EMAIL|*", $subscriber->email, $body_html); $body_html = str_replace("*|ID|*", $subscriber->subscriberID, $body_html); } $open_info = array("id" => $this->subscriber_id(), "report" => $this->id(), "view" => "open"); $code = SendPress_Data::encrypt($open_info); $link = SendPress_Manager::public_url($code); $tracker = "<img src='" . $link . "' width='1' height='1'/></body>"; $body_html = str_replace("</body>", $tracker, $body_html); $body_link = get_post_meta($this->id(), 'body_link', true); $body_html = spnl_do_subscriber_tags($body_html, $post_template, $this->id(), $this->subscriber_id(), true); //$pattern ="/(?<=href=(\"|'))[^\"']+(?=(\"|'))/"; //$body_html = preg_replace( $pattern , site_url() ."?sendpress=link&fxti=".$subscriber_key."&spreport=". $this->id ."&spurl=$0", $body_html ); if (class_exists("DomDocument")) { $dom = new DomDocument(); $dom->strictErrorChecking = false; @$dom->loadHtml($body_html); $pTags = $dom->getElementsByTagName('p'); foreach ($pTags as $pElement) { $px = $pElement->getAttribute('style'); $pElement->setAttribute('style', $px . ' margin-top:0;margin-bottom:10px;'); } if ($this->tracker()) { $aTags = $dom->getElementsByTagName('a'); foreach ($aTags as $aElement) { $href = $aElement->getAttribute('href'); /* $style = $aElement->getAttribute('style'); if($style == ""){ $aElement->setAttribute('style'); } */ //ADD TO DB? if (strrpos($href, "*|") === false && strrpos($href, "#") !== 0) { if (SendPress_Option::get('skip_mailto', false) == true && strrpos($href, "mailto") !== false) { continue; } /* $urlinDB = SendPress_Data::get_url_by_report_url( $this->id(), $href ); if(!isset($urlinDB[0])){ $urlData = array( 'url' => trim($href), 'reportID' => $this->id(), ); $urlID = SendPress_Data::insert_report_url( $urlData ); } else { $urlID = $urlinDB[0]->urlID; } $link = array( "id"=>$this->subscriber_id(), "report"=> $this->id(), "urlID"=> $urlID, "view"=>"link" ); */ $link = array("id" => $this->subscriber_id(), "report" => $this->id(), "view" => "tracker", "url" => $href); $code = SendPress_Data::encrypt($link); $link = SendPress_Manager::public_url($code); $href = $link; $aElement->setAttribute('href', $href); } } } $body_html = $dom->saveHtml(); } $link_data = array("id" => $this->subscriber_id(), "report" => $this->id(), "urlID" => '0', "view" => "manage", "listID" => $this->list_id(), "action" => "unsubscribe"); $code = SendPress_Data::encrypt($link_data); $link = SendPress_Manager::public_url($code); if (SendPress_Option::get('old_unsubscribe_link', false) === true) { $start_text = __("Not interested anymore?", "sendpress"); $unsubscribe = __("Unsubscribe", "sendpress"); $instantly = __("Instantly", "sendpress"); $remove_me_old = $start_text . ' <a href="' . $link . '" style="color: ' . $body_link . ';" >' . $unsubscribe . '</a> ' . $instantly . '.'; $body_html = str_replace("*|SP:UNSUBSCRIBE|*", $remove_me_old, $body_html); $body_html = str_replace("*|SP:MANAGE|*", '', $body_html); } else { $link_data = array("id" => $this->subscriber_id(), "report" => $this->id(), "urlID" => '0', "view" => "manage", "listID" => $this->list_id(), "action" => ""); $code = SendPress_Data::encrypt($link_data); $manage_link = SendPress_Manager::public_url($code); $unsubscribe = __("Unsubscribe", "sendpress"); $manage = __("Manage Subscription", "sendpress"); $remove_me = ' <a href="' . $link . '" style="color: ' . $body_link . ';" >' . $unsubscribe . '</a> | '; $manage = ' <a href="' . $manage_link . '" style="color: ' . $body_link . ';" >' . $manage . '</a> '; $body_html = str_replace("*|SP:UNSUBSCRIBE|*", $remove_me, $body_html); $body_html = str_replace("*|SP:MANAGE|*", $manage, $body_html); } if (!is_null($subscriber)) { $body_html = str_replace("*|FNAME|*", $subscriber->firstname, $body_html); $body_html = str_replace("*|LNAME|*", $subscriber->lastname, $body_html); $body_html = str_replace("*|EMAIL|*", $subscriber->email, $body_html); $body_html = str_replace("*|ID|*", $subscriber->subscriberID, $body_html); } //$body_html = apply_filters('sendpress_post_render_email', $body_html); //echo $body_html; //print_r($email); return $body_html; }
function html($sp) { global $current_user; global $post_ID, $post; $view = isset($_GET['view']) ? $_GET['view'] : ''; $list = ''; if (isset($_GET['emailID'])) { $emailID = $_GET['emailID']; $post = get_post($_GET['emailID']); $post_ID = $post->ID; } $post_type = $sp->_email_post_type; $post_type_object = get_post_type_object($sp->_email_post_type); ?> <div class="alert alert-danger fade hide"> <?php _e('<strong>Notice!</strong> You must select a list below before an email can be sent.', 'sendpress'); ?> </div> <form method="POST" name="sendpress_post" id="sendpress_post"> <div style="float:right;" class="btn-toolbar"> <div id="sp-cancel-btn" class="btn-group"> <a href="?page=<?php echo $_GET['page']; ?> " class="btn btn-default "><?php echo __('Cancel', 'sendpress'); ?> </a> </div> <div class="btn-group"> <!--<button class="btn btn-default " type="submit" value="save" name="submit"><i class="icon-white icon-ok"></i> <?php echo __('Edit', 'sendpress'); ?> </button>--> <button class="btn btn-primary " type="submit" value="save-next" id="sp-send-next" name="submit"><i class="icon-envelope icon-white"></i> <?php echo __('Send', 'sendpress'); ?> </button> </div> </div> <input type="hidden" id="user-id" name="user_ID" value="<?php echo $current_user->ID; ?> " /> <input type="hidden" id="post_ID" name="post_ID" value="<?php echo $post->ID; ?> " /> <input type="hidden" id="post_type" name="post_type" value="sp_newsletters" /> <h2><?php _e('Send Email', 'sendpress'); ?> </h2> <br> <div class="boxer"> <div class="boxer-inner"> <?php $this->panel_start('<span class="glyphicon glyphicon-inbox"></span> ' . __('Subject', 'sendpress')); ?> <input type="text" class="form-control" name="post_subject" size="30" tabindex="1" value="<?php echo esc_attr(htmlspecialchars(get_post_meta($post->ID, '_sendpress_subject', true))); ?> " id="email-subject" autocomplete="off" /> <?php $this->panel_end(); ?> <div class="leftcol"> <?php $this->panel_start('<span class="glyphicon glyphicon-calendar"></span> ' . __('Date & Time', 'sendpress')); ?> <input type="radio" name="send-date" value="now" checked/> <?php _e('Start Sending Now', 'sendpress'); ?> <br> <input type="radio" name="send-date" value="later"/> <?php _e('Send Later', 'sendpress'); ?> <br> <div class="date-holder" style="display:none"> <br> <input type="text" name="date-pickit" id="date-pickit" class=" fifty float-left" value="<?php echo date_i18n('Y/m/d'); ?> "/> at <script type="text/javascript"> jQuery(document).ready(function($) { $(".date-holder").hide(); $('input[type=radio][name=send-date]').change(function() { if (this.value == 'now') { $(".date-holder").hide(); } else if (this.value == 'later') { $(".date-holder").show(); } }); $('#date-pickit').datepicker({ dateFormat : 'yy/mm/dd' }); }); </script> <select name="send-later-time" id="datepicker-time" class="fifty"> <option value="00:00:00">12:00 am</option> <option value="01:00:00">1:00 am</option> <option value="02:00:00">2:00 am</option> <option value="03:00:00">3:00 am</option> <option value="04:00:00">4:00 am</option> <option value="05:00:00">5:00 am</option> <option value="06:00:00">6:00 am</option> <option value="07:00:00">7:00 am</option> <option value="08:00:00">8:00 am</option> <option value="09:00:00">9:00 am</option> <option value="10:00:00">10:00 am</option> <option value="11:00:00">11:00 am</option> <option value="12:00:00">12:00 pm</option> <option value="13:00:00">1:00 pm</option> <option value="14:00:00">2:00 pm</option> <option value="15:00:00">3:00 pm</option> <option value="16:00:00">4:00 pm</option> <option value="17:00:00">5:00 pm</option> <option value="18:00:00">6:00 pm</option> <option value="19:00:00">7:00 pm</option> <option value="20:00:00">8:00 pm</option> <option value="21:00:00">9:00 pm</option> <option value="22:00:00">10:00 pm</option> <option value="23:00:00">11:00 pm</option> </select> </div> <?php $this->panel_end(); do_action('spnl_add_to_sending', $this); $this->panel_start('<span class="glyphicon glyphicon-list"></span> ' . __('Lists', 'sendpress')); $post_args = array('post_type' => 'sendpress_list', 'numberposts' => -1, 'offset' => 0, 'orderby' => 'post_title', 'order' => 'DESC'); $current_lists = get_posts($post_args); foreach ($current_lists as $list) { $t = ''; $tlist = ''; if (get_post_meta($list->ID, '_test_list', true) == 1) { $t = ' <span class="label label-info">Test List</span>'; $tlist = ' test-list-add'; } echo "<input name='listIDS[]' type='checkbox' id='listIDS' class='sp-send-lists " . $tlist . "' value=" . $list->ID . "> " . $list->post_title . " <small>(" . SendPress_Data::get_count_subscribers($list->ID) . ")</small>{$t}<br>"; } $this->panel_end(); $this->panel_start('<span class="glyphicon glyphicon-tag"></span> ' . __('Mark as Test', 'sendpress')); echo "<input name='test_report' type='checkbox' id='test_report' value='1'> " . __('Test', 'sendpress') . "<br>"; echo "<small class='text-muted'> " . __('This puts the report into the Test tab on the Reports screen', 'sendpress') . ".</small>"; $this->panel_end(); ?> <!-- <div class="style-unit"> <h4><?php _e('Settings', 'sendpress'); ?> </h4> <input type="checkbox" name="test-send" value="1" /> Mark as Test <textarea name="test-add" cols='26' rows='6'></textarea> </div> --> <?php wp_nonce_field($sp->_nonce_value); ?> </div> <div style="margin-left: 250px;"> <div class="widerightcol"> <?php $url = get_site_url(); //$link = get_permalink( $post->ID ); $open_info = array("id" => $post->ID, "view" => "email"); $code = SendPress_Data::encrypt($open_info); $url = SendPress_Manager::public_url($code); $sep = strstr($url, '?') ? '&' : '?'; $link = $url . $sep . 'inline=true'; ?> <iframe src="<?php echo $link; ?> " width="100%" height="600px"></iframe> <small><?php _e('Displaying a 404? Please try saving your permalinks', 'sendpress'); ?> <a href="<?php echo admin_url('options-permalink.php'); ?> "><?php _e('here', 'sendpress'); ?> </a>.</small> </div> </div> <br class="clear" /> </div> </form> <?php }
function send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id) { $phpmailer = new SendPress_PHPMailer(); /* * Make sure the mailer thingy is clean before we start, should not * be necessary, but who knows what others are doing to our mailer */ $phpmailer->ClearAddresses(); $phpmailer->ClearAllRecipients(); $phpmailer->ClearAttachments(); $phpmailer->ClearBCCs(); $phpmailer->ClearCCs(); $phpmailer->ClearCustomHeaders(); $phpmailer->ClearReplyTos(); $charset = SendPress_Option::get('email-charset', 'UTF-8'); $encoding = SendPress_Option::get('email-encoding', '8bit'); $phpmailer->CharSet = $charset; $phpmailer->Encoding = $encoding; if ($charset != 'UTF-8') { $html = $this->change($html, 'UTF-8', $charset); $text = $this->change($text, 'UTF-8', $charset); $subject = $this->change($subject, 'UTF-8', $charset); } $from_email = SendPress_Option::get('fromemail'); $phpmailer->From = $from_email; $phpmailer->FromName = SendPress_Option::get('fromname'); //$subject = str_replace(array('’','“','�','–'),array("'",'"','"','-'),$subject); //$html = str_replace(chr(194),chr(32),$html); //$text = str_replace(chr(194),chr(32),$text); //return $email; $phpmailer->AddAddress(trim($to)); $phpmailer->AltBody = $text; $phpmailer->Subject = $subject; $content_type = 'text/html'; $phpmailer->MsgHTML($html); $phpmailer->ContentType = $content_type; // Set whether it's plaintext, depending on $content_type //if ( 'text/html' == $content_type ) $phpmailer->IsHTML(true); $hosting = SendPress_Option::get('website-hosting-provider'); if ($hosting == 'godaddy') { // We are sending SMTP mail $phpmailer->IsSMTP(); // Set the other options $phpmailer->Host = 'relay-hosting.secureserver.net'; } // If we don't have a charset from the input headers //if ( !isset( $charset ) ) //$charset = get_bloginfo( 'charset' ); // Set the content-type and charset /** * We'll let php init mess with the message body and headers. But then * we stomp all over it. Sorry, my plug-inis more important than yours :) */ do_action_ref_array('phpmailer_init', array(&$phpmailer)); //$phpmailer->Sender = '*****@*****.**';//SendPress_Option::get('fromemail'); $hdr = new SendPress_SendGrid_SMTP_API(); $hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email)); //$phpmailer->AddCustomHeader( sprintf( 'X-SP-MID: %s',$email->messageID ) ); $phpmailer->AddCustomHeader(sprintf('X-SMTPAPI: %s', $hdr->asJSON())); $phpmailer->AddCustomHeader('X-SP-METHOD: website'); // Set SMTPDebug to 2 will collect dialogue between us and the mail server $phpmailer->AddCustomHeader('X-SP-LIST: ' . $list_id); $phpmailer->AddCustomHeader('X-SP-REPORT: ' . $report_id); $phpmailer->AddCustomHeader('X-SP-SUBSCRIBER: ' . $sid); if ($istest == true) { $phpmailer->SMTPDebug = 2; // Start output buffering to grab smtp output ob_start(); } // Send! $result = true; // start with true, meaning no error $result = @$phpmailer->Send(); //$phpmailer->SMTPClose(); if ($istest == true) { // Grab the smtp debugging output $smtp_debug = ob_get_clean(); SendPress_Option::set('phpmailer_error', $phpmailer->ErrorInfo); SendPress_Option::set('last_test_debug', $smtp_debug); //$this->last_send_smtp_debug = $smtp_debug; } if ($result != true) { $log_message = 'Website <br>'; $log_message .= $to . "<br>"; if ($istest == true) { $log_message .= "<br><br>"; $log_message .= $smtp_debug; } //$phpmailer->ErrorInfo SPNL()->log->add($phpmailer->ErrorInfo, $log_message, 0, 'sending'); } if ($result != true && $istest == true) { $hostmsg = 'host: ' . $phpmailer->Host . ' port: ' . $phpmailer->Port . ' secure: ' . $phpmailer->SMTPSecure . ' auth: ' . $phpmailer->SMTPAuth . ' user: '******''; $msg .= __('The result was: ', 'sendpress') . $result . "\n"; $msg .= __('The mailer error info: ', 'sendpress') . $phpmailer->ErrorInfo . "\n"; $msg .= $hostmsg; $msg .= __("The SMTP debugging output is shown below:\n", "sendpress"); $msg .= $smtp_debug . "\n"; //$msg .= 'The full debugging output(exported mailer) is shown below:\n'; //$msg .= var_export($phpmailer,true)."\n"; //$this->append_log($msg); } return $result; }
function send_batch() { $this->verify_ajax_call(); $count = SendPress_Manager::send_single_from_queue(); echo json_encode($count); exit; }
function reset_counters() { SendPress_Manager::reset_counters(); SendPress_Admin::redirect('Queue'); }
static function send_notification($body = "Possible Error With Notifications", $text = "Possible Error With Notifications") { $options = SendPress_Option::get('notification_options'); $senders = array(); if (strlen($options['email']) > 0) { $senders = explode(",", $options['email']); } if ($options['send-to-admins']) { $admins = new WP_User_Query(array('role' => 'Administrator')); foreach ($admins->results as $user) { if ($user->user_email !== $options['email']) { $senders[] = $user->user_email; } } } if ($options['notifications-enable']) { if (is_array($senders) && !empty($senders)) { foreach ($senders as $to) { SendPress_Manager::send(trim($to), 'SendPress Notification', $body, $text); } } } //hipchat if ($options['enable-hipchat'] && strlen($options['hipchat-api']) > 0) { global $hc; $hc = new SendPress_HipChat($options['hipchat-api'], 'https://api.hipchat.com'); try { foreach ($hc->get_rooms() as $room) { if ($options['hipchat-rooms'][$room->room_id]) { $hc->message_room($room->name, 'SendPress', $text, true, "purple", "text"); } } } catch (Exception $e) { $hc->message_room($options['hipchat-room'], 'SendPress', $text, true, "purple", "text"); } } }
static function old_send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id) { global $phpmailer, $wpdb; // (Re)create it, if it's gone missing if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) { require_once ABSPATH . WPINC . '/class-phpmailer.php'; require_once ABSPATH . WPINC . '/class-smtp.php'; $phpmailer = new PHPMailer(); } /* * Make sure the mailer thingy is clean before we start, should not * be necessary, but who knows what others are doing to our mailer */ $phpmailer->ClearAddresses(); $phpmailer->ClearAllRecipients(); $phpmailer->ClearAttachments(); $phpmailer->ClearBCCs(); $phpmailer->ClearCCs(); $phpmailer->ClearCustomHeaders(); $phpmailer->ClearReplyTos(); //return $email; // $charset = SendPress_Option::get('email-charset', 'UTF-8'); $encoding = SendPress_Option::get('email-encoding', '8bit'); $phpmailer->CharSet = $charset; $phpmailer->Encoding = $encoding; if ($charset != 'UTF-8') { $sender = new SendPress_Sender(); $html = $sender->change($html, 'UTF-8', $charset); $text = $sender->change($text, 'UTF-8', $charset); $subject = $sender->change($subject, 'UTF-8', $charset); } $subject = str_replace(array('’', '“', '�', '–'), array("'", '"', '"', '-'), $subject); $html = str_replace(chr(194), chr(32), $html); $text = str_replace(chr(194), chr(32), $text); $phpmailer->AddAddress(trim($to)); $phpmailer->AltBody = $text; $phpmailer->Subject = $subject; $phpmailer->MsgHTML($html); $content_type = 'text/html'; $phpmailer->ContentType = $content_type; // Set whether it's plaintext, depending on $content_type //if ( 'text/html' == $content_type ) $phpmailer->IsHTML(true); /** * We'll let php init mess with the message body and headers. But then * we stomp all over it. Sorry, my plug-inis more important than yours :) */ do_action_ref_array('phpmailer_init', array(&$phpmailer)); $from_email = SendPress_Option::get('fromemail'); $phpmailer->From = $from_email; $phpmailer->FromName = SendPress_Option::get('fromname'); $phpmailer->Sender = SendPress_Option::get('fromemail'); $sending_method = SendPress_Option::get('sendmethod'); $phpmailer = apply_filters('sendpress_sending_method_' . $sending_method, $phpmailer); $hdr = new SendPress_SendGrid_SMTP_API(); $hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email)); $phpmailer->AddCustomHeader(sprintf('X-SMTPAPI: %s', $hdr->asJSON())); $phpmailer->AddCustomHeader('X-SP-METHOD: old'); // Set SMTPDebug to 2 will collect dialogue between us and the mail server if ($istest == true) { $phpmailer->SMTPDebug = 2; // Start output buffering to grab smtp output ob_start(); } // Send! $result = true; // start with true, meaning no error $result = @$phpmailer->Send(); //$phpmailer->SMTPClose(); if ($istest == true) { // Grab the smtp debugging output $smtp_debug = ob_get_clean(); SendPress_Option::set('phpmailer_error', $phpmailer->ErrorInfo); SendPress_Option::set('last_test_debug', $smtp_debug); } if ($result != true && $istest == true) { $hostmsg = 'host: ' . $phpmailer->Host . ' port: ' . $phpmailer->Port . ' secure: ' . $phpmailer->SMTPSecure . ' auth: ' . $phpmailer->SMTPAuth . ' user: '******''; $msg .= __('The result was: ', 'sendpress') . $result . "\n"; $msg .= __('The mailer error info: ', 'sendpress') . $phpmailer->ErrorInfo . "\n"; $msg .= $hostmsg; $msg .= __("The SMTP debugging output is shown below:\n", "sendpress"); $msg .= $smtp_debug . "\n"; } return $result; }
function send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id) { $phpmailer = new SendPress_PHPMailer(); /* * Make sure the mailer thingy is clean before we start, should not * be necessary, but who knows what others are doing to our mailer */ // If we don't have a charset from the input headers $phpmailer->ClearAddresses(); $phpmailer->ClearAllRecipients(); $phpmailer->ClearAttachments(); $phpmailer->ClearBCCs(); $phpmailer->ClearCCs(); $phpmailer->ClearCustomHeaders(); $phpmailer->ClearReplyTos(); //return $email; $charset = SendPress_Option::get('email-charset', 'UTF-8'); $encoding = SendPress_Option::get('email-encoding', '8bit'); $phpmailer->CharSet = $charset; $phpmailer->Encoding = $encoding; if ($charset != 'UTF-8') { $html = $this->change($html, 'UTF-8', $charset); $text = $this->change($text, 'UTF-8', $charset); $subject = $this->change($subject, 'UTF-8', $charset); } /** * We'll let php init mess with the message body and headers. But then * we stomp all over it. Sorry, my plug-inis more important than yours :) */ do_action_ref_array('phpmailer_init', array(&$phpmailer)); $from_email = SendPress_Option::get('fromemail'); $phpmailer->From = $from_email; $phpmailer->FromName = SendPress_Option::get('fromname'); //$phpmailer->Sender = '*****@*****.**'; //$phpmailer->Sender = SendPress_Option::get('fromemail'); $sending_method = SendPress_Option::get('sendmethod'); //$subject = str_replace(array('’','“','�','–'),array("'",'"','"','-'),$subject); //$html = str_replace(chr(194),chr(32),$html); //$text = str_replace(chr(194),chr(32),$text); $phpmailer->AddAddress(trim($to)); $phpmailer->AltBody = $text; $phpmailer->Subject = $subject; $phpmailer->MsgHTML($html); $content_type = 'text/html'; $phpmailer->ContentType = $content_type; // Set whether it's plaintext, depending on $content_type //if ( 'text/html' == $content_type ) $phpmailer->IsHTML(true); $rpath = SendPress_Option::get('bounce_email'); if ($rpath != false) { $phpmailer->ReturnPath = $rpath; $phpmailer->AddReplyTo($rpath, SendPress_Option::get('fromname')); } $phpmailer->Mailer = 'smtp'; // We are sending SMTP mail $phpmailer->IsSMTP(); // Set the other options $phpmailer->Host = 'smtp.gmail.com'; $phpmailer->SMTPAuth = true; // authentication enabled $phpmailer->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail $phpmailer->Port = 587; // If we're using smtp auth, set the username & password $phpmailer->SMTPAuth = TRUE; $phpmailer->Username = SendPress_Option::get('gmailuser'); $phpmailer->Password = SendPress_Option::get('gmailpass'); $hdr = new SendPress_SendGrid_SMTP_API(); $hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email)); $phpmailer->AddCustomHeader(sprintf('X-SMTPAPI: %s', $hdr->asJSON())); $phpmailer->AddCustomHeader('X-SP-METHOD: Gmail'); $phpmailer->AddCustomHeader('X-SP-LIST: ' . $list_id); $phpmailer->AddCustomHeader('X-SP-REPORT: ' . $report_id); $phpmailer->AddCustomHeader('X-SP-SUBSCRIBER: ' . $sid); $phpmailer->AddCustomHeader('List-Unsubscribe: <mailto:' . $from_email . '>'); // Set SMTPDebug to 2 will collect dialogue between us and the mail server if ($istest == true) { $phpmailer->SMTPDebug = 2; // Start output buffering to grab smtp output ob_start(); } // Send! $result = true; // start with true, meaning no error $result = @$phpmailer->Send(); //$phpmailer->SMTPClose(); if ($istest == true) { // Grab the smtp debugging output $smtp_debug = ob_get_clean(); SendPress_Option::set('phpmailer_error', $phpmailer->ErrorInfo); SendPress_Option::set('last_test_debug', $smtp_debug); } if ($result == true) { SendPress_Option::set('phpmailer_error', __('Nenhum erro encontrado', 'jaiminho')); } if ($result != true) { $log_message = 'Gmail <br>'; $log_message .= $to . "<br>"; if ($istest == true) { $log_message .= "<br><br>"; $log_message .= $smtp_debug; } //$phpmailer->ErrorInfo SPNL()->log->add($phpmailer->ErrorInfo, $log_message, 0, 'sending'); } if ($result != true && $istest == true) { $hostmsg = 'host: ' . $phpmailer->Host . ' port: ' . $phpmailer->Port . ' secure: ' . $phpmailer->SMTPSecure . ' auth: ' . $phpmailer->SMTPAuth . ' user: '******''; $msg .= __('The result was: ', 'sendpress') . $result . "\n"; $msg .= __('The mailer error info: ', 'sendpress') . $phpmailer->ErrorInfo . "\n"; $msg .= $hostmsg; $msg .= __("The SMTP debugging output is shown below:\n", "sendpress"); $msg .= $smtp_debug . "\n"; } return $result; }