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;
 }
Ejemplo n.º 2
0
 function init()
 {
     //add_action('register_form',array( $this , 'add_registration_fields'));
     SendPress_Ajax_Loader::init();
     //SendPress_Signup_Shortcode::init();
     SendPress_Sender::init();
     SendPress_Cron::get_instance();
     SendPress_Videos::init();
     sendpress_register_sender('SendPress_Sender_Website');
     sendpress_register_sender('SendPress_Sender_Gmail');
     add_action('sendpress_event', array('SendPress_Tracking', 'event'), 1, 1);
     do_action('sendpress_init');
     SendPress_Admin::add_cap('Emails_Send', 'sendpress_email_send');
     $indexer = "";
     $permalinks = get_option('permalink_structure');
     if ($permalinks) {
         $pos = strpos($permalinks, "index.php");
         if ($pos > 0) {
             // note: three equal signs
             $indexer = "index.php/";
         }
     }
     add_rewrite_rule("^{$indexer}sendpress/([^/]+)/?", 'index.php?sendpress=$matches[1]', "top");
     if (defined('WP_ADMIN') && WP_ADMIN == true) {
         $sendpress_screen_options = new SendPress_Screen_Options();
     }
     $this->add_custom_post();
     //add_filter( 'cron_schedules', array($this,'cron_schedule' ));
     //add_action( 'wp_loaded', array( $this, 'add_cron' ) );
     if (is_admin()) {
         SendPress_Pro_Manager::init();
         SendPress_Tracking::init();
         SendPress_Notifications_Manager::init();
         if (isset($_GET['spv'])) {
             SendPress_Option::set('version', $_GET['spv']);
         }
         if (isset($_GET['sp-admin-code']) && current_user_can('manage_options')) {
             switch ($_GET['sp-admin-code']) {
                 case 'install-tables':
                     $this->install_tables();
                     break;
                 case 'remove-key':
                     SendPress_Option::set('api_key', '');
                     SendPress_Pro_Manager::set_pro_state(false);
                     //this will delete the transient
                     break;
                 default:
                     # code...
                     break;
             }
         }
         $this->ready_for_sending();
         add_action('admin_menu', array($this, 'admin_menu'));
         add_action('admin_init', array($this, 'admin_init'));
         add_action('admin_notices', array($this, 'admin_notice'));
         add_action('admin_print_scripts', array($this, 'editor_insidepopup'));
         add_filter('gettext', array($this, 'change_button_text'), null, 2);
         add_action('sendpress_notices', array($this, 'sendpress_notices'));
         add_filter('user_has_cap', array($this, 'user_has_cap'), 10, 3);
         //SendPress_Option::set('default-signup-widget-settings',false);
     } else {
         if (SendPress_Option::get('sp_widget_shortdoces')) {
             add_filter('widget_text', 'do_shortcode');
         }
     }
     add_image_size('sendpress-max', 600, 600);
     add_filter('template_include', array($this, 'template_include'), 5);
     add_action('sendpress_cron_action', array($this, 'sendpress_cron_action_run'));
     //using this for now, might find a different way to include things later
     // global $load_signup_js;
     // $load_signup_js = false;
     add_action('wp_enqueue_scripts', array($this, 'add_front_end_scripts'));
     add_action('wp_enqueue_scripts', array($this, 'add_front_end_styles'));
     add_action('wp_head', array($this, 'handle_front_end_posts'));
 }