コード例 #1
0
 public function configure_phpmailer($phpmailer)
 {
     $settings = SparkPost::get_settings();
     if (!$settings['enable_sparkpost'] || empty($settings['password'])) {
         return;
     }
     $tracking_enabled = (bool) $settings['enable_tracking'];
     $x_msys_api = array('options' => array('open_tracking' => (bool) apply_filters('wpsp_open_tracking', $tracking_enabled), 'click_tracking' => (bool) apply_filters('wpsp_click_tracking', $tracking_enabled), 'transactional' => (bool) apply_filters('wpsp_transactional', $settings['transactional'])));
     $phpmailer->isSMTP();
     $phpmailer->SMTPSecure = 'tls';
     $phpmailer->Port = !empty($settings['port']) ? intval($settings['port']) : 587;
     $phpmailer->Host = 'smtp.sparkpostmail.com';
     $phpmailer->SMTPAuth = true;
     $phpmailer->Username = '******';
     $phpmailer->Password = apply_filters('wpsp_api_key', $settings['password']);
     $json_x_msys_api = apply_filters('wpsp_smtp_msys_api', json_encode($x_msys_api));
     $phpmailer->addCustomHeader('X-MSYS-API', $json_x_msys_api);
 }
コード例 #2
0
Plugin Name: SparkPost
Plugin URI: http://sparkpost.com/
Description: Send all your email from Wordpress through SparkPost, the world's most advanced email delivery service.
Version: 2.4.1
Author: SparkPost
Author URI: http://sparkpost.com
License: GPLv2 or later
Text Domain: wpsp
*/
// If ABSPATH is defined, we assume WP is calling us.
// Otherwise, this could be an illicit direct request.
if (!defined('ABSPATH')) {
    exit;
}
define('WPSP_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('WPSP_PLUGIN_PATH', WPSP_PLUGIN_DIR . basename(__FILE__));
require_once WPSP_PLUGIN_DIR . 'sparkpost.class.php';
if (is_admin()) {
    require_once WPSP_PLUGIN_DIR . 'admin.widget.class.php';
    new SparkPostAdmin();
}
$sp = new SparkPost();
if (SparkPost::get_setting('enable_sparkpost')) {
    if (SparkPost::get_setting('sending_method') == 'smtp') {
        require_once WPSP_PLUGIN_DIR . 'mailer.smtp.class.php';
        new SparkPostSMTPMailer();
    } else {
        require_once WPSP_PLUGIN_DIR . 'mailer.http.class.php';
        add_filter('wp_mail', array($sp, 'init_sp_http_mailer'));
    }
}
コード例 #3
0
 public function render_password_field()
 {
     $api_key = SparkPost::obfuscate_api_key($this->settings['password']);
     printf('<input type="text" id="password" name="sp_settings[password]" class="regular-text" value="%s" /><br/>
         <small><ul><li>For SMTP, set up an API key with the <strong>Send via SMTP</strong> permission</li> <li>For HTTP API, set up an API Key with the <strong>Transmissions: Read/Write</strong> permission</li><a href="https://support.sparkpost.com/customer/portal/articles/1933377-create-api-keys" target="_blank">Need help creating a SparkPost API key?</a></small>', isset($api_key) ? $api_key : '');
 }
コード例 #4
0
 protected function get_request_headers($hide_api_key = false)
 {
     $api_key = apply_filters('wpsp_api_key', $this->settings['password']);
     if ($hide_api_key) {
         $api_key = SparkPost::obfuscate_api_key($api_key);
     }
     return apply_filters('wpsp_request_headers', array('User-Agent' => 'wordpress-sparkpost', 'Content-Type' => 'application/json', 'Authorization' => $api_key));
 }