updated plugin WP Mail SMTP version 2.4.0

This commit is contained in:
2020-09-25 14:44:17 +00:00
committed by Gitium
parent 4f3d745449
commit 3053837189
673 changed files with 31869 additions and 65613 deletions

View File

@ -3,6 +3,7 @@
namespace WPMailSMTP\Admin;
use WPMailSMTP\Debug;
use WPMailSMTP\Options;
/**
* WP Mail SMTP admin bar menu.
@ -73,6 +74,10 @@ class AdminBarMenu {
*/
public function enqueues() {
if ( ! is_admin_bar_showing() ) {
return;
}
if ( ! $this->has_access() ) {
return;
}
@ -97,7 +102,10 @@ class AdminBarMenu {
if (
! $this->has_access() ||
(
empty( Debug::get_last() ) &&
(
empty( Debug::get_last() ) ||
(bool) Options::init()->get( 'general', 'email_delivery_errors_hidden' )
) &&
empty( $this->has_notifications() )
)
) {
@ -128,7 +136,10 @@ class AdminBarMenu {
*/
public function main_menu( \WP_Admin_Bar $wp_admin_bar ) {
if ( ! empty( Debug::get_last() ) ) {
if (
! empty( Debug::get_last() ) &&
! (bool) Options::init()->get( 'general', 'email_delivery_errors_hidden' )
) {
$indicator = ' <span class="wp-mail-smtp-admin-bar-menu-error">!</span>';
} elseif ( ! empty( $this->has_notifications() ) ) {
$count = $this->has_notifications() < 10 ? $this->has_notifications() : '!';

View File

@ -3,6 +3,7 @@
namespace WPMailSMTP\Admin;
use WPMailSMTP\Options;
use WPMailSMTP\Tasks\Tasks;
use WPMailSMTP\WP;
/**
@ -238,7 +239,7 @@ class Notifications {
// Update notifications using async task.
if ( empty( $option['update'] ) || time() > $option['update'] + DAY_IN_SECONDS ) {
if ( empty( wp_mail_smtp()->get_tasks()->is_scheduled( 'wp_mail_smtp_admin_notifications_update' ) ) ) {
if ( empty( Tasks::is_scheduled( 'wp_mail_smtp_admin_notifications_update' ) ) ) {
wp_mail_smtp()->get_tasks()
->create( 'wp_mail_smtp_admin_notifications_update' )

View File

@ -1,45 +1,45 @@
<?php
namespace WPMailSMTP\Admin;
/**
* Class PageInterface defines what should be in each page class.
*
* @since 1.0.0
*/
interface PageInterface {
/**
* URL to a tab.
*
* @since 1.0.0
*
* @return string
*/
public function get_link();
/**
* Title of a tab.
*
* @since 1.0.0
*
* @return string
*/
public function get_title();
/**
* Link label of a tab.
*
* @since 1.0.0
*
* @return string
*/
public function get_label();
/**
* Tab content.
*
* @since 1.0.0
*/
public function display();
}
<?php
namespace WPMailSMTP\Admin;
/**
* Class PageInterface defines what should be in each page class.
*
* @since 1.0.0
*/
interface PageInterface {
/**
* URL to a tab.
*
* @since 1.0.0
*
* @return string
*/
public function get_link();
/**
* Title of a tab.
*
* @since 1.0.0
*
* @return string
*/
public function get_title();
/**
* Link label of a tab.
*
* @since 1.0.0
*
* @return string
*/
public function get_label();
/**
* Tab content.
*
* @since 1.0.0
*/
public function display();
}

View File

@ -649,12 +649,13 @@ class About extends PageAbstract {
*/
private function get_license_features() {
return array(
'log' => \esc_html__( 'Email Log', 'wp-mail-smtp' ),
'control' => \esc_html__( 'Email Controls', 'wp-mail-smtp' ),
'mailers' => \esc_html__( 'Additional Mailers', 'wp-mail-smtp' ),
'support' => \esc_html__( 'Customer Support', 'wp-mail-smtp' ),
);
return [
'log' => \esc_html__( 'Email Log', 'wp-mail-smtp' ),
'control' => \esc_html__( 'Email Controls', 'wp-mail-smtp' ),
'mailers' => \esc_html__( 'Mailer Options', 'wp-mail-smtp' ),
'multisite' => \esc_html__( 'WordPress Multisite', 'wp-mail-smtp' ),
'support' => \esc_html__( 'Customer Support', 'wp-mail-smtp' ),
];
}
/**
@ -669,64 +670,78 @@ class About extends PageAbstract {
*/
private function get_license_data( $feature, $license ) {
$data = array(
'log' => array(
'lite' => array(
$data = [
'log' => [
'lite' => [
'status' => 'none',
'text' => array(
'text' => [
'<strong>' . esc_html__( 'Emails are not logged', 'wp-mail-smtp' ) . '</strong>',
),
),
'pro' => array(
],
],
'pro' => [
'status' => 'full',
'text' => array(
'<strong>' . esc_html__( 'Complete Email Log management inside WordPress', 'wp-mail-smtp' ) . '</strong>',
),
),
),
'control' => array(
'lite' => array(
'text' => [
'<strong>' . esc_html__( 'Access to all Email Logging options right inside WordPress', 'wp-mail-smtp' ) . '</strong>',
],
],
],
'control' => [
'lite' => [
'status' => 'none',
'text' => array(
'text' => [
'<strong>' . esc_html__( 'No controls over whether default WordPress emails are sent', 'wp-mail-smtp' ) . '</strong>',
),
),
'pro' => array(
],
],
'pro' => [
'status' => 'full',
'text' => array(
'text' => [
'<strong>' . esc_html__( 'Complete Email Controls management for most default WordPress emails', 'wp-mail-smtp' ) . '</strong>',
),
),
),
'mailers' => array(
'lite' => array(
],
],
],
'mailers' => [
'lite' => [
'status' => 'none',
'text' => array(
'<strong>' . esc_html__( 'Only default list of mailers', 'wp-mail-smtp' ) . '</strong>',
),
),
'pro' => array(
'text' => [
'<strong>' . esc_html__( 'Limited Mailers', 'wp-mail-smtp' ) . '</strong><br>' . esc_html__( 'Access is limited to standard mailer options only', 'wp-mail-smtp' ),
],
],
'pro' => [
'status' => 'full',
'text' => array(
'<strong>' . esc_html__( 'Additional mailers: Microsoft Outlook (with Office365 support) and Amazon SES', 'wp-mail-smtp' ) . '</strong>',
),
),
),
'support' => array(
'lite' => array(
'text' => [
'<strong>' . esc_html__( 'Additional Mailer Options', 'wp-mail-smtp' ) . '</strong><br>' . esc_html__( 'Microsoft Outlook (with Office365 support), Amazon SES and Zoho Mail', 'wp-mail-smtp' ),
],
],
],
'multisite' => [
'lite' => [
'status' => 'none',
'text' => array(
'text' => [
'<strong>' . esc_html__( 'No Global Network Settings', 'wp-mail-smtp' ) . '</strong>',
],
],
'pro' => [
'status' => 'full',
'text' => [
'<strong>' . esc_html__( 'All Global Network Settings', 'wp-mail-smtp' ) . '</strong><br>' . esc_html__( 'Optionally configure settings at the network level or manage separately for each subsite', 'wp-mail-smtp' ),
],
],
],
'support' => [
'lite' => [
'status' => 'none',
'text' => [
'<strong>' . esc_html__( 'Limited Support', 'wp-mail-smtp' ) . '</strong>',
),
),
'pro' => array(
],
],
'pro' => [
'status' => 'full',
'text' => array(
'text' => [
'<strong>' . esc_html__( 'Priority Support', 'wp-mail-smtp' ) . '</strong>',
),
),
),
);
],
],
],
];
// Wrong feature?
if ( ! isset( $data[ $feature ] ) ) {

View File

@ -1,63 +1,63 @@
<?php
namespace WPMailSMTP\Admin\Pages;
use WPMailSMTP\Options;
use WPMailSMTP\Providers\AuthAbstract;
/**
* Class AuthTab.
*
* @since 1.0.0
*/
class AuthTab {
/**
* @var string Slug of a tab.
*/
protected $slug = 'auth';
/**
* Launch mailer specific Auth logic.
*
* @since 1.0.0
*/
public function process_auth() {
$auth = wp_mail_smtp()->get_providers()->get_auth( Options::init()->get( 'mail', 'mailer' ) );
if (
$auth &&
$auth instanceof AuthAbstract &&
method_exists( $auth, 'process' )
) {
$auth->process();
}
}
/**
* Return nothing, as we don't need this functionality.
*
* @since 1.0.0
*/
public function get_label() {
return '';
}
/**
* Return nothing, as we don't need this functionality.
*
* @since 1.0.0
*/
public function get_title() {
return '';
}
/**
* Do nothing, as we don't need this functionality.
*
* @since 1.0.0
*/
public function display() {
}
}
<?php
namespace WPMailSMTP\Admin\Pages;
use WPMailSMTP\Options;
use WPMailSMTP\Providers\AuthAbstract;
/**
* Class AuthTab.
*
* @since 1.0.0
*/
class AuthTab {
/**
* @var string Slug of a tab.
*/
protected $slug = 'auth';
/**
* Launch mailer specific Auth logic.
*
* @since 1.0.0
*/
public function process_auth() {
$auth = wp_mail_smtp()->get_providers()->get_auth( Options::init()->get( 'mail', 'mailer' ) );
if (
$auth &&
$auth instanceof AuthAbstract &&
method_exists( $auth, 'process' )
) {
$auth->process();
}
}
/**
* Return nothing, as we don't need this functionality.
*
* @since 1.0.0
*/
public function get_label() {
return '';
}
/**
* Return nothing, as we don't need this functionality.
*
* @since 1.0.0
*/
public function get_title() {
return '';
}
/**
* Do nothing, as we don't need this functionality.
*
* @since 1.0.0
*/
public function display() {
}
}

View File

@ -1,184 +1,184 @@
<?php
namespace WPMailSMTP;
/**
* Class Conflicts
*
* @since 1.5.0
*/
class Conflicts {
/**
* @since 1.5.0
*
* @var array List of plugins WP Mail SMTP may be conflicting with.
*/
public static $plugins = array(
'swpsmtp_init_smtp' => array(
'name' => 'Easy WP SMTP',
),
'postman_start' => array(
'name' => 'Postman SMTP',
),
'post_start' => array(
'name' => 'Post SMTP Mailer/Email Log',
),
'mail_bank' => array(
'name' => 'WP Mail Bank',
),
'SMTP_MAILER' => array(
'name' => 'SMTP Mailer',
'class' => true,
),
'GMAIL_SMTP' => array(
'name' => 'Gmail SMTP',
'class' => true,
),
'WP_Email_Smtp' => array(
'name' => 'WP Email SMTP',
'class' => true,
),
'smtpmail_include' => array(
'name' => 'SMTP Mail',
),
'bwssmtp_init' => array(
'name' => 'SMTP by BestWebSoft',
),
'WPSendGrid_SMTP' => array(
'name' => 'WP SendGrid SMTP',
'class' => true,
),
'sar_friendly_smtp' => array(
'name' => 'SAR Friendly SMTP',
),
'WPGmail_SMTP' => array(
'name' => 'WP Gmail SMTP',
'class' => true,
),
'st_smtp_check_config' => array(
'name' => 'Cimy Swift SMTP',
),
'WP_Easy_SMTP' => array(
'name' => 'WP Easy SMTP',
'class' => true,
),
'WPMailgun_SMTP' => array(
'name' => 'WP Mailgun SMTP',
'class' => true,
),
'my_smtp_wp' => array(
'name' => 'MY SMTP WP',
),
'mail_booster' => array(
'name' => 'WP Mail Booster',
),
'Sendgrid_Settings' => array(
'name' => 'SendGrid',
'class' => true,
),
'WPMS_php_mailer' => array(
'name' => 'WP Mail Smtp Mailer',
),
'WPAmazonSES_SMTP' => array(
'name' => 'WP Amazon SES SMTP',
'class' => true,
),
'Postmark_Mail' => array(
'name' => 'Postmark for WordPress',
'class' => true,
),
'Mailgun' => array(
'name' => 'Mailgun',
'class' => true,
),
'WPSparkPost\SparkPost' => array(
'name' => 'SparkPost',
'class' => true,
),
'WPYahoo_SMTP' => array(
'name' => 'WP Yahoo SMTP',
'class' => true,
),
'wpses_init' => array(
'name' => 'WP SES',
'class' => true,
),
'TSPHPMailer' => array(
'name' => 'turboSMTP',
),
'WP_SMTP' => array(
'name' => 'WP SMTP',
'class' => true,
),
);
/**
* @var array Conflict information.
*/
protected $conflict = array();
/**
* Whether we have a conflict with predefined list of plugins.
*
* @since 1.5.0
*
* @return bool
*/
public function is_detected() {
foreach ( self::$plugins as $callback => $plugin ) {
if ( ! empty( $plugin['class'] ) ) {
$detected = \class_exists( $callback, false );
} else {
$detected = \function_exists( $callback );
}
if ( $detected ) {
$this->conflict = $plugin;
break;
}
}
return ! empty( $this->conflict );
}
/**
* Add a warning admin message to a user about the conflicting plugin.
*
* @since 1.5.0
*/
public function notify() {
if ( empty( $this->conflict ) ) {
return;
}
WP::add_admin_notice(
\sprintf( /* translators: %1$s - Plugin name causing conflict; %2$s - Plugin name causing conflict. */
\esc_html__( 'Heads up! WP Mail SMTP has detected %1$s is activated. Please deactivate %2$s to prevent conflicts.', 'wp-mail-smtp' ),
$this->get_conflict_name(),
$this->get_conflict_name()
),
WP::ADMIN_NOTICE_WARNING
);
}
/**
* Get the conflicting plugin name is any.
*
* @since 1.5.0
*
* @return null|string
*/
public function get_conflict_name() {
$name = null;
if ( ! empty( $this->conflict['name'] ) ) {
$name = $this->conflict['name'];
}
return $name;
}
}
<?php
namespace WPMailSMTP;
/**
* Class Conflicts
*
* @since 1.5.0
*/
class Conflicts {
/**
* @since 1.5.0
*
* @var array List of plugins WP Mail SMTP may be conflicting with.
*/
public static $plugins = array(
'swpsmtp_init_smtp' => array(
'name' => 'Easy WP SMTP',
),
'postman_start' => array(
'name' => 'Postman SMTP',
),
'post_start' => array(
'name' => 'Post SMTP Mailer/Email Log',
),
'mail_bank' => array(
'name' => 'WP Mail Bank',
),
'SMTP_MAILER' => array(
'name' => 'SMTP Mailer',
'class' => true,
),
'GMAIL_SMTP' => array(
'name' => 'Gmail SMTP',
'class' => true,
),
'WP_Email_Smtp' => array(
'name' => 'WP Email SMTP',
'class' => true,
),
'smtpmail_include' => array(
'name' => 'SMTP Mail',
),
'bwssmtp_init' => array(
'name' => 'SMTP by BestWebSoft',
),
'WPSendGrid_SMTP' => array(
'name' => 'WP SendGrid SMTP',
'class' => true,
),
'sar_friendly_smtp' => array(
'name' => 'SAR Friendly SMTP',
),
'WPGmail_SMTP' => array(
'name' => 'WP Gmail SMTP',
'class' => true,
),
'st_smtp_check_config' => array(
'name' => 'Cimy Swift SMTP',
),
'WP_Easy_SMTP' => array(
'name' => 'WP Easy SMTP',
'class' => true,
),
'WPMailgun_SMTP' => array(
'name' => 'WP Mailgun SMTP',
'class' => true,
),
'my_smtp_wp' => array(
'name' => 'MY SMTP WP',
),
'mail_booster' => array(
'name' => 'WP Mail Booster',
),
'Sendgrid_Settings' => array(
'name' => 'SendGrid',
'class' => true,
),
'WPMS_php_mailer' => array(
'name' => 'WP Mail Smtp Mailer',
),
'WPAmazonSES_SMTP' => array(
'name' => 'WP Amazon SES SMTP',
'class' => true,
),
'Postmark_Mail' => array(
'name' => 'Postmark for WordPress',
'class' => true,
),
'Mailgun' => array(
'name' => 'Mailgun',
'class' => true,
),
'WPSparkPost\SparkPost' => array(
'name' => 'SparkPost',
'class' => true,
),
'WPYahoo_SMTP' => array(
'name' => 'WP Yahoo SMTP',
'class' => true,
),
'wpses_init' => array(
'name' => 'WP SES',
'class' => true,
),
'TSPHPMailer' => array(
'name' => 'turboSMTP',
),
'WP_SMTP' => array(
'name' => 'WP SMTP',
'class' => true,
),
);
/**
* @var array Conflict information.
*/
protected $conflict = array();
/**
* Whether we have a conflict with predefined list of plugins.
*
* @since 1.5.0
*
* @return bool
*/
public function is_detected() {
foreach ( self::$plugins as $callback => $plugin ) {
if ( ! empty( $plugin['class'] ) ) {
$detected = \class_exists( $callback, false );
} else {
$detected = \function_exists( $callback );
}
if ( $detected ) {
$this->conflict = $plugin;
break;
}
}
return ! empty( $this->conflict );
}
/**
* Add a warning admin message to a user about the conflicting plugin.
*
* @since 1.5.0
*/
public function notify() {
if ( empty( $this->conflict ) ) {
return;
}
WP::add_admin_notice(
\sprintf( /* translators: %1$s - Plugin name causing conflict; %2$s - Plugin name causing conflict. */
\esc_html__( 'Heads up! WP Mail SMTP has detected %1$s is activated. Please deactivate %2$s to prevent conflicts.', 'wp-mail-smtp' ),
$this->get_conflict_name(),
$this->get_conflict_name()
),
WP::ADMIN_NOTICE_WARNING
);
}
/**
* Get the conflicting plugin name is any.
*
* @since 1.5.0
*
* @return null|string
*/
public function get_conflict_name() {
$name = null;
if ( ! empty( $this->conflict['name'] ) ) {
$name = $this->conflict['name'];
}
return $name;
}
}

View File

@ -953,4 +953,29 @@ class Core {
return $notifications;
}
/**
* Prepare the HTML output for a plugin loader/spinner.
*
* @since 2.4.0
*
* @param string $color The color of the loader ('', 'blue' or 'white'), where '' is default orange.
* @param string $size The size of the loader ('lg', 'md', 'sm').
*
* @return string
*/
public function prepare_loader( $color = '', $size = 'md' ) {
$svg_name = 'loading';
if ( in_array( $color, [ 'blue', 'white' ], true ) ) {
$svg_name .= '-' . $color;
}
if ( ! in_array( $size, [ 'lg', 'md', 'sm' ], true ) ) {
$size = 'md';
}
return '<img src="' . esc_url( $this->plugin_url . '/assets/images/loaders/' . $svg_name . '.svg' ) . '" alt="' . esc_html__( 'Loading', 'wp-mail-smtp' ) . '" class="wp-mail-smtp-loading wp-mail-smtp-loading-' . $size . '">';
}
}

View File

@ -50,15 +50,15 @@ class Geo {
* @since 1.6.0 Added new geo API endpoint, provided by WPForms.
* @since 2.0.0 Updated the WPForms geo API endpoint to v3.
*
* @param string $ip
* @param string $ip The IP address.
*
* @return array Empty array for localhost.
*/
public static function get_location_by_ip( $ip ) {
// Check for a non-local IP.
if ( empty( $ip ) || in_array( $ip, array( '127.0.0.1', '::1' ), true ) ) {
return array();
if ( empty( $ip ) || in_array( $ip, [ '127.0.0.1', '::1' ], true ) ) {
return [];
}
$request = wp_remote_get( 'https://geo.wpforms.com/v3/geolocate/json/' . $ip );
@ -66,14 +66,14 @@ class Geo {
if ( ! is_wp_error( $request ) ) {
$request = json_decode( wp_remote_retrieve_body( $request ), true );
if ( ! empty( $request['latitude'] ) && ! empty( $request['longitude'] ) ) {
$data = array(
$data = [
'latitude' => sanitize_text_field( $request['latitude'] ),
'longitude' => sanitize_text_field( $request['longitude'] ),
'city' => sanitize_text_field( $request['city'] ),
'region' => sanitize_text_field( $request['region_name'] ),
'country' => sanitize_text_field( $request['country_iso'] ),
'postal' => sanitize_text_field( $request['zip_code'] ),
);
'city' => isset( $request['city'] ) ? sanitize_text_field( $request['city'] ) : '',
'region' => isset( $request['region_name'] ) ? sanitize_text_field( $request['region_name'] ) : '',
'country' => isset( $request['country_iso'] ) ? sanitize_text_field( $request['country_iso'] ) : '',
'postal' => isset( $request['zip_code'] ) ? sanitize_text_field( $request['zip_code'] ) : '',
];
return $data;
}
@ -87,14 +87,14 @@ class Geo {
if ( ! empty( $request['latitude'] ) && ! empty( $request['longitude'] ) ) {
$data = array(
$data = [
'latitude' => sanitize_text_field( $request['latitude'] ),
'longitude' => sanitize_text_field( $request['longitude'] ),
'city' => sanitize_text_field( $request['city'] ),
'region' => sanitize_text_field( $request['region'] ),
'country' => sanitize_text_field( $request['country'] ),
'postal' => sanitize_text_field( $request['postal'] ),
);
'city' => isset( $request['city'] ) ? sanitize_text_field( $request['city'] ) : '',
'region' => isset( $request['region'] ) ? sanitize_text_field( $request['region'] ) : '',
'country' => isset( $request['country'] ) ? sanitize_text_field( $request['country'] ) : '',
'postal' => isset( $request['postal'] ) ? sanitize_text_field( $request['postal'] ) : '',
];
return $data;
}
@ -108,20 +108,20 @@ class Geo {
if ( ! empty( $request['data']['geo']['latitude'] ) && ! empty( $request['data']['geo']['longitude'] ) ) {
$data = array(
$data = [
'latitude' => sanitize_text_field( $request['data']['geo']['latitude'] ),
'longitude' => sanitize_text_field( $request['data']['geo']['longitude'] ),
'city' => sanitize_text_field( $request['data']['geo']['city'] ),
'region' => sanitize_text_field( $request['data']['geo']['region_name'] ),
'country' => sanitize_text_field( $request['data']['geo']['country_code'] ),
'postal' => sanitize_text_field( $request['data']['geo']['postal_code'] ),
);
'city' => isset( $request['data']['geo']['city'] ) ? sanitize_text_field( $request['data']['geo']['city'] ) : '',
'region' => isset( $request['data']['geo']['region_name'] ) ? sanitize_text_field( $request['data']['geo']['region_name'] ) : '',
'country' => isset( $request['data']['geo']['country_code'] ) ? sanitize_text_field( $request['data']['geo']['country_code'] ) : '',
'postal' => isset( $request['data']['geo']['postal_code'] ) ? sanitize_text_field( $request['data']['geo']['postal_code'] ) : '',
];
return $data;
}
}
return array();
return [];
}
/**

View File

@ -166,4 +166,16 @@ class MailCatcher extends \PHPMailer implements MailCatcherInterface {
return $this->LE; // phpcs:ignore
}
/**
* Create a unique ID to use for multipart email boundaries.
*
* @since 2.4.0
*
* @return string
*/
public function generate_id() {
return $this->generateId();
}
}

View File

@ -30,4 +30,13 @@ interface MailCatcherInterface {
* @return string
*/
public function get_line_ending();
/**
* Create a unique ID to use for multipart email boundaries.
*
* @since 2.4.0
*
* @return string
*/
public function generate_id();
}

View File

@ -146,4 +146,16 @@ class MailCatcherV6 extends \PHPMailer\PHPMailer\PHPMailer implements MailCatche
return static::$LE; // phpcs:ignore
}
/**
* Create a unique ID to use for multipart email boundaries.
*
* @since 2.4.0
*
* @return string
*/
public function generate_id() {
return $this->generateId();
}
}

View File

@ -23,8 +23,6 @@ class Options {
* @since 1.8.0 Added Pepipost API.
* @since 2.0.0 Added SMTP.com API.
*
* @since
*
* @var array Map of all the default options of the plugin.
*/
private static $map = [
@ -62,7 +60,6 @@ class Options {
'client_id',
'client_secret',
'region',
'emails_pending',
],
'mailgun' => [
'api_key',
@ -99,6 +96,8 @@ class Options {
* That's where plugin options are saved in wp_options table.
*
* @since 1.0.0
*
* @var string
*/
const META_KEY = 'wp_mail_smtp';
@ -126,7 +125,7 @@ class Options {
*
* One-liner:
* Options::init()->get('smtp', 'host');
* Options::init()->is_pepipost_active();
* Options::init()->is_mailer_active( 'pepipost' );
*
* Or multiple-usage:
* $options = new Options();
@ -329,10 +328,6 @@ class Options {
$value = $group === 'mailgun' ? 'US' : $value;
break;
case 'emails_pending':
$value = array();
break;
case 'auth':
case 'autotls':
$value = in_array( $group, array( 'smtp', 'pepipost' ), true ) ? false : true;
@ -921,7 +916,6 @@ class Options {
case 'access_token': // gmail/outlook/zoho, is an array.
case 'user_details': // outlook/zoho, is an array.
case 'emails_pending': // amazonses, array().
// These options don't support constants.
$options[ $mailer ][ $option_name ] = $option_value;
break;
@ -996,12 +990,21 @@ class Options {
/**
* Check whether the site is using Pepipost SMTP or not.
*
* @deprecated 2.4.0
*
* @since 1.0.0
*
* @return bool
*/
public function is_pepipost_active() {
return apply_filters( 'wp_mail_smtp_options_is_pepipost_active', $this->get( 'mail', 'mailer' ) === 'pepipost' );
_deprecated_function(
__METHOD__,
'2.4.0',
'WPMailSMTP\Options::is_mailer_active()'
);
return apply_filters( 'wp_mail_smtp_options_is_pepipost_active', $this->is_mailer_active( 'pepipost' ) );
}
/**

View File

@ -1,44 +1,44 @@
<?php
namespace WPMailSMTP\Providers\AmazonSES;
use WPMailSMTP\Providers\OptionsAbstract;
/**
* Class Options.
*
* @since 1.7.0
*/
class Options extends OptionsAbstract {
/**
* AmazonSES Options constructor.
*
* @since 1.7.0
*/
public function __construct() {
parent::__construct(
array(
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/aws.svg',
'slug' => 'amazonses',
'title' => esc_html__( 'Amazon SES', 'wp-mail-smtp' ),
'disabled' => true,
)
);
}
/**
* @inheritdoc
*/
public function display_options() {
?>
<p>
<?php esc_html_e( 'We\'re sorry, the Amazon SES mailer is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wp-mail-smtp' ); ?>
</p>
<?php
}
}
<?php
namespace WPMailSMTP\Providers\AmazonSES;
use WPMailSMTP\Providers\OptionsAbstract;
/**
* Class Options.
*
* @since 1.7.0
*/
class Options extends OptionsAbstract {
/**
* AmazonSES Options constructor.
*
* @since 1.7.0
*/
public function __construct() {
parent::__construct(
array(
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/aws.svg',
'slug' => 'amazonses',
'title' => esc_html__( 'Amazon SES', 'wp-mail-smtp' ),
'disabled' => true,
)
);
}
/**
* @inheritdoc
*/
public function display_options() {
?>
<p>
<?php esc_html_e( 'We\'re sorry, the Amazon SES mailer is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wp-mail-smtp' ); ?>
</p>
<?php
}
}

View File

@ -1,148 +1,148 @@
<?php
namespace WPMailSMTP\Providers;
use WPMailSMTP\Options as PluginOptions;
/**
* Class AuthAbstract.
*
* @since 1.0.0
*/
abstract class AuthAbstract implements AuthInterface {
/**
* Mailer DB options.
*
* @since 1.0.0
*
* @var array
*/
protected $options = array();
/**
* @since 1.0.0
*
* @var mixed
*/
protected $client;
/**
* Mailer slug.
*
* @since 1.0.0
*
* @var string
*/
protected $mailer_slug = '';
/**
* Key for a stored unique state value.
*
* @since 1.5.0
*
* @var string
*/
public $state_key = 'wp_mail_smtp_provider_client_state';
/**
* Use the composer autoloader to include the auth library and all dependencies.
*
* @since 1.0.0
*/
protected function include_vendor_lib() {
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
}
/**
* Get the url, that users will be redirected back to finish the OAuth process.
*
* @since 1.0.0
*
* @return string
*/
public static function get_plugin_auth_url() {
return add_query_arg( 'tab', 'auth', wp_mail_smtp()->get_admin()->get_admin_page_url() );
}
/**
* Update auth code in our DB.
*
* @since 1.0.0
*
* @param string $code
*/
protected function update_auth_code( $code ) {
$options = new PluginOptions();
$all = $options->get_all();
// To save in DB.
$all[ $this->mailer_slug ]['auth_code'] = $code;
// To save in currently retrieved options array.
$this->options['auth_code'] = $code;
$options->set( $all );
}
/**
* Update access token in our DB.
*
* @since 1.0.0
*
* @param mixed $token
*/
protected function update_access_token( $token ) {
$options = new PluginOptions();
$all = $options->get_all();
// To save in DB.
$all[ $this->mailer_slug ]['access_token'] = $token;
// To save in currently retrieved options array.
$this->options['access_token'] = $token;
$options->set( $all );
}
/**
* Update refresh token in our DB.
*
* @since 1.0.0
*
* @param mixed $token
*/
protected function update_refresh_token( $token ) {
$options = new PluginOptions();
$all = $options->get_all();
// To save in DB.
$all[ $this->mailer_slug ]['refresh_token'] = $token;
// To save in currently retrieved options array.
$this->options['refresh_token'] = $token;
$options->set( $all );
}
/**
* @inheritdoc
*/
public function is_clients_saved() {
return ! empty( $this->options['client_id'] ) && ! empty( $this->options['client_secret'] );
}
/**
* @inheritdoc
*/
public function is_auth_required() {
return empty( $this->options['access_token'] ) || empty( $this->options['refresh_token'] );
}
}
<?php
namespace WPMailSMTP\Providers;
use WPMailSMTP\Options as PluginOptions;
/**
* Class AuthAbstract.
*
* @since 1.0.0
*/
abstract class AuthAbstract implements AuthInterface {
/**
* Mailer DB options.
*
* @since 1.0.0
*
* @var array
*/
protected $options = array();
/**
* @since 1.0.0
*
* @var mixed
*/
protected $client;
/**
* Mailer slug.
*
* @since 1.0.0
*
* @var string
*/
protected $mailer_slug = '';
/**
* Key for a stored unique state value.
*
* @since 1.5.0
*
* @var string
*/
public $state_key = 'wp_mail_smtp_provider_client_state';
/**
* Use the composer autoloader to include the auth library and all dependencies.
*
* @since 1.0.0
*/
protected function include_vendor_lib() {
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
}
/**
* Get the url, that users will be redirected back to finish the OAuth process.
*
* @since 1.0.0
*
* @return string
*/
public static function get_plugin_auth_url() {
return add_query_arg( 'tab', 'auth', wp_mail_smtp()->get_admin()->get_admin_page_url() );
}
/**
* Update auth code in our DB.
*
* @since 1.0.0
*
* @param string $code
*/
protected function update_auth_code( $code ) {
$options = new PluginOptions();
$all = $options->get_all();
// To save in DB.
$all[ $this->mailer_slug ]['auth_code'] = $code;
// To save in currently retrieved options array.
$this->options['auth_code'] = $code;
$options->set( $all );
}
/**
* Update access token in our DB.
*
* @since 1.0.0
*
* @param mixed $token
*/
protected function update_access_token( $token ) {
$options = new PluginOptions();
$all = $options->get_all();
// To save in DB.
$all[ $this->mailer_slug ]['access_token'] = $token;
// To save in currently retrieved options array.
$this->options['access_token'] = $token;
$options->set( $all );
}
/**
* Update refresh token in our DB.
*
* @since 1.0.0
*
* @param mixed $token
*/
protected function update_refresh_token( $token ) {
$options = new PluginOptions();
$all = $options->get_all();
// To save in DB.
$all[ $this->mailer_slug ]['refresh_token'] = $token;
// To save in currently retrieved options array.
$this->options['refresh_token'] = $token;
$options->set( $all );
}
/**
* @inheritdoc
*/
public function is_clients_saved() {
return ! empty( $this->options['client_id'] ) && ! empty( $this->options['client_secret'] );
}
/**
* @inheritdoc
*/
public function is_auth_required() {
return empty( $this->options['access_token'] ) || empty( $this->options['refresh_token'] );
}
}

View File

@ -1,30 +1,30 @@
<?php
namespace WPMailSMTP\Providers;
/**
* Interface AuthInterface.
*
* @since 1.0.0
*/
interface AuthInterface {
/**
* Whether user saved Client ID/App ID and Client Secret/App Password or not.
* Both options are required.
*
* @since 1.0.0
*
* @return bool
*/
public function is_clients_saved();
/**
* Whether we have an access and refresh tokens or not.
*
* @since 1.0.0
*
* @return bool
*/
public function is_auth_required();
}
<?php
namespace WPMailSMTP\Providers;
/**
* Interface AuthInterface.
*
* @since 1.0.0
*/
interface AuthInterface {
/**
* Whether user saved Client ID/App ID and Client Secret/App Password or not.
* Both options are required.
*
* @since 1.0.0
*
* @return bool
*/
public function is_clients_saved();
/**
* Whether we have an access and refresh tokens or not.
*
* @since 1.0.0
*
* @return bool
*/
public function is_auth_required();
}

View File

@ -6,6 +6,8 @@ use WPMailSMTP\Admin\Area;
use WPMailSMTP\Debug;
use WPMailSMTP\Options as PluginOptions;
use WPMailSMTP\Providers\AuthAbstract;
use WPMailSMTP\Vendor\Google_Client;
use WPMailSMTP\Vendor\Google_Service_Gmail;
/**
* Class Auth to request access and refresh tokens.
@ -74,7 +76,7 @@ class Auth extends AuthAbstract {
* @since 1.0.0
* @since 1.5.0 Add ability to apply custom options to the client via a filter.
*
* @return \Google_Client
* @return Google_Client
*/
public function get_client() {
@ -85,7 +87,7 @@ class Auth extends AuthAbstract {
$this->include_vendor_lib();
$client = new \Google_Client(
$client = new Google_Client(
array(
'client_id' => $this->options['client_id'],
'client_secret' => $this->options['client_secret'],
@ -99,7 +101,7 @@ class Auth extends AuthAbstract {
$client->setApprovalPrompt( 'force' );
$client->setIncludeGrantedScopes( true );
// We request only the sending capability, as it's what we only need to do.
$client->setScopes( array( \Google_Service_Gmail::MAIL_GOOGLE_COM ) );
$client->setScopes( array( Google_Service_Gmail::MAIL_GOOGLE_COM ) );
$client->setRedirectUri( self::get_plugin_auth_url() );
// Apply custom options to the client.
@ -224,13 +226,13 @@ class Auth extends AuthAbstract {
if (
! empty( $code ) &&
(
$scope === \Google_Service_Gmail::MAIL_GOOGLE_COM . ' ' . \Google_Service_Gmail::GMAIL_SEND ||
$scope === \Google_Service_Gmail::GMAIL_SEND . ' ' . \Google_Service_Gmail::MAIL_GOOGLE_COM ||
$scope === \Google_Service_Gmail::GMAIL_SEND ||
$scope === \Google_Service_Gmail::MAIL_GOOGLE_COM
$scope === Google_Service_Gmail::MAIL_GOOGLE_COM . ' ' . Google_Service_Gmail::GMAIL_SEND ||
$scope === Google_Service_Gmail::GMAIL_SEND . ' ' . Google_Service_Gmail::MAIL_GOOGLE_COM ||
$scope === Google_Service_Gmail::GMAIL_SEND ||
$scope === Google_Service_Gmail::MAIL_GOOGLE_COM
)
) {
// Save the auth code. So \Google_Client can reuse it to retrieve the access token.
// Save the auth code. So Google_Client can reuse it to retrieve the access token.
$this->update_auth_code( $code );
} else {
wp_safe_redirect(
@ -264,8 +266,8 @@ class Auth extends AuthAbstract {
if (
! empty( $this->client ) &&
class_exists( 'Google_Client', false ) &&
$this->client instanceof \Google_Client
class_exists( 'WPMailSMTP\Vendor\Google_Client', false ) &&
$this->client instanceof Google_Client
) {
return filter_var( $this->client->createAuthUrl(), FILTER_SANITIZE_URL );
}
@ -282,7 +284,7 @@ class Auth extends AuthAbstract {
*/
public function get_user_info() {
$gmail = new \Google_Service_Gmail( $this->get_client() );
$gmail = new Google_Service_Gmail( $this->get_client() );
try {
$email = $gmail->users->getProfile( 'me' )->getEmailAddress();
@ -306,20 +308,18 @@ class Auth extends AuthAbstract {
return $this->aliases;
}
$gmail = new \Google_Service_Gmail( $this->get_client() );
$gmail = new Google_Service_Gmail( $this->get_client() );
try {
$response = $gmail->users_settings_sendAs->listUsersSettingsSendAs( 'me' ); // phpcs:ignore
// phpcs:disable
if ( isset( $response->sendAs ) ) {
$this->aliases = array_map(
function( $sendAsObject ) {
return $sendAsObject->sendAsEmail;
},
$response->sendAs
);
}
$this->aliases = array_map(
function( $sendAsObject ) {
return $sendAsObject['sendAsEmail'];
},
(array) $response->getSendAs()
);
// phpcs:enable
} catch ( \Exception $exception ) {

View File

@ -5,6 +5,8 @@ namespace WPMailSMTP\Providers\Gmail;
use WPMailSMTP\Debug;
use WPMailSMTP\MailCatcherInterface;
use WPMailSMTP\Providers\MailerAbstract;
use WPMailSMTP\Vendor\Google_Service_Gmail;
use WPMailSMTP\Vendor\Google_Service_Gmail_Message;
/**
* Class Mailer.
@ -28,7 +30,7 @@ class Mailer extends MailerAbstract {
*
* @since 1.0.0
*
* @var \Google_Service_Gmail_Message
* @var Google_Service_Gmail_Message
*/
protected $message;
@ -76,7 +78,7 @@ class Mailer extends MailerAbstract {
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
$auth = new Auth();
$message = new \Google_Service_Gmail_Message();
$message = new Google_Service_Gmail_Message();
// Set the authorized Gmail email address as the "from email" if the set email is not on the list of aliases.
$possible_from_emails = $auth->get_user_possible_send_from_addresses();
@ -103,7 +105,7 @@ class Mailer extends MailerAbstract {
$message->setRaw( $base64 );
$service = new \Google_Service_Gmail( $auth->get_client() );
$service = new Google_Service_Gmail( $auth->get_client() );
$response = $service->users_messages->send( 'me', $message );
$this->process_response( $response );
@ -123,7 +125,7 @@ class Mailer extends MailerAbstract {
* @since 1.0.0
* @since 1.5.0 Added action "wp_mail_smtp_providers_gmail_mailer_process_response" with $response.
*
* @param \Google_Service_Gmail_Message $response Instance of Gmail response.
* @param Google_Service_Gmail_Message $response Instance of Gmail response.
*/
protected function process_response( $response ) {

View File

@ -25,8 +25,8 @@ class Loader {
protected $providers = array(
'mail' => 'WPMailSMTP\Providers\Mail\\',
'smtpcom' => 'WPMailSMTP\Providers\SMTPcom\\',
'pepipostapi' => 'WPMailSMTP\Providers\PepipostAPI\\',
'sendinblue' => 'WPMailSMTP\Providers\Sendinblue\\',
'pepipostapi' => 'WPMailSMTP\Providers\PepipostAPI\\',
'mailgun' => 'WPMailSMTP\Providers\Mailgun\\',
'sendgrid' => 'WPMailSMTP\Providers\Sendgrid\\',
'amazonses' => 'WPMailSMTP\Providers\AmazonSES\\',
@ -53,7 +53,7 @@ class Loader {
*/
public function get_providers() {
if ( ! Options::init()->is_pepipost_active() ) {
if ( ! Options::init()->is_mailer_active( 'pepipost' ) ) {
unset( $this->providers['pepipost'] );
}

View File

@ -1,49 +1,49 @@
<?php
namespace WPMailSMTP\Providers\Mail;
use WPMailSMTP\Providers\MailerAbstract;
/**
* Class Mailer inherits everything from parent abstract class.
* This file is required for a proper work of Loader and \ReflectionClass.
*
* @package WPMailSMTP\Providers\Mail
*/
class Mailer extends MailerAbstract {
/**
* @inheritdoc
*/
public function get_debug_info() {
$mail_text = array();
$mail_text[] = '<br><strong>Server:</strong>';
$disabled_functions = ini_get( 'disable_functions' );
$disabled = (array) explode( ',', trim( $disabled_functions ) );
$mail_text[] = '<strong>PHP.mail():</strong> ' . ( in_array( 'mail', $disabled, true ) || ! function_exists( 'mail' ) ? 'No' : 'Yes' );
if ( function_exists( 'apache_get_modules' ) ) {
$modules = apache_get_modules();
$mail_text[] = '<strong>Apache.mod_security:</strong> ' . ( in_array( 'mod_security', $modules, true ) || in_array( 'mod_security2', $modules, true ) ? 'Yes' : 'No' );
}
if ( function_exists( 'selinux_is_enabled' ) ) {
$mail_text[] = '<strong>OS.SELinux:</strong> ' . ( selinux_is_enabled() ? 'Yes' : 'No' );
}
if ( function_exists( 'grsecurity_is_enabled' ) ) {
$mail_text[] = '<strong>OS.grsecurity:</strong> ' . ( grsecurity_is_enabled() ? 'Yes' : 'No' );
}
return implode( '<br>', $mail_text );
}
/**
* @inheritdoc
*/
public function is_mailer_complete() {
return true;
}
}
<?php
namespace WPMailSMTP\Providers\Mail;
use WPMailSMTP\Providers\MailerAbstract;
/**
* Class Mailer inherits everything from parent abstract class.
* This file is required for a proper work of Loader and \ReflectionClass.
*
* @package WPMailSMTP\Providers\Mail
*/
class Mailer extends MailerAbstract {
/**
* @inheritdoc
*/
public function get_debug_info() {
$mail_text = array();
$mail_text[] = '<br><strong>Server:</strong>';
$disabled_functions = ini_get( 'disable_functions' );
$disabled = (array) explode( ',', trim( $disabled_functions ) );
$mail_text[] = '<strong>PHP.mail():</strong> ' . ( in_array( 'mail', $disabled, true ) || ! function_exists( 'mail' ) ? 'No' : 'Yes' );
if ( function_exists( 'apache_get_modules' ) ) {
$modules = apache_get_modules();
$mail_text[] = '<strong>Apache.mod_security:</strong> ' . ( in_array( 'mod_security', $modules, true ) || in_array( 'mod_security2', $modules, true ) ? 'Yes' : 'No' );
}
if ( function_exists( 'selinux_is_enabled' ) ) {
$mail_text[] = '<strong>OS.SELinux:</strong> ' . ( selinux_is_enabled() ? 'Yes' : 'No' );
}
if ( function_exists( 'grsecurity_is_enabled' ) ) {
$mail_text[] = '<strong>OS.grsecurity:</strong> ' . ( grsecurity_is_enabled() ? 'Yes' : 'No' );
}
return implode( '<br>', $mail_text );
}
/**
* @inheritdoc
*/
public function is_mailer_complete() {
return true;
}
}

View File

@ -1,42 +1,42 @@
<?php
namespace WPMailSMTP\Providers\Mail;
use WPMailSMTP\Providers\OptionsAbstract;
/**
* Class Option.
*
* @since 1.0.0
*/
class Options extends OptionsAbstract {
/**
* Mail constructor.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
array(
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/php.svg',
'slug' => 'mail',
'title' => esc_html__( 'Default (none)', 'wp-mail-smtp' ),
)
);
}
/**
* @inheritdoc
*/
public function display_options() {
?>
<blockquote>
<?php esc_html_e( 'You currently have the native WordPress option selected. Please select any other Mailer option above to continue the setup.', 'wp-mail-smtp' ); ?>
</blockquote>
<?php
}
}
<?php
namespace WPMailSMTP\Providers\Mail;
use WPMailSMTP\Providers\OptionsAbstract;
/**
* Class Option.
*
* @since 1.0.0
*/
class Options extends OptionsAbstract {
/**
* Mail constructor.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
array(
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/php.svg',
'slug' => 'mail',
'title' => esc_html__( 'Default (none)', 'wp-mail-smtp' ),
)
);
}
/**
* @inheritdoc
*/
public function display_options() {
?>
<blockquote>
<?php esc_html_e( 'You currently have the native WordPress option selected. Please select any other Mailer option above to continue the setup.', 'wp-mail-smtp' ); ?>
</blockquote>
<?php
}
}

View File

@ -227,7 +227,7 @@ class Mailer extends MailerAbstract {
*
* @since 1.0.0
*
* @param array $attachments
* @param array $attachments The array of attachments data.
*/
public function set_attachments( $attachments ) {
@ -249,8 +249,7 @@ class Mailer extends MailerAbstract {
if ( is_file( $attachment[0] ) && is_readable( $attachment[0] ) ) {
$file = file_get_contents( $attachment[0] );
}
}
catch ( \Exception $e ) {
} catch ( \Exception $e ) {
$file = false;
}
@ -267,7 +266,7 @@ class Mailer extends MailerAbstract {
if ( ! empty( $data ) ) {
// First, generate a boundary for the multipart message.
$boundary = base_convert( uniqid( 'boundary', true ), 10, 36 );
$boundary = $this->phpmailer->generate_id();
// Iterate through pre-built params and build a payload.
foreach ( $this->body as $key => $value ) {

View File

@ -1,44 +1,44 @@
<?php
namespace WPMailSMTP\Providers\Outlook;
use WPMailSMTP\Providers\OptionsAbstract;
/**
* Class Options.
*
* @since 1.7.0
*/
class Options extends OptionsAbstract {
/**
* Outlook Options constructor.
*
* @since 1.7.0
*/
public function __construct() {
parent::__construct(
array(
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/microsoft.svg',
'slug' => 'outlook',
'title' => esc_html__( 'Outlook', 'wp-mail-smtp' ),
'disabled' => true,
)
);
}
/**
* @inheritdoc
*/
public function display_options() {
?>
<p>
<?php esc_html_e( 'We\'re sorry, the Microsoft Outlook mailer is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wp-mail-smtp' ); ?>
</p>
<?php
}
}
<?php
namespace WPMailSMTP\Providers\Outlook;
use WPMailSMTP\Providers\OptionsAbstract;
/**
* Class Options.
*
* @since 1.7.0
*/
class Options extends OptionsAbstract {
/**
* Outlook Options constructor.
*
* @since 1.7.0
*/
public function __construct() {
parent::__construct(
array(
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/microsoft.svg',
'slug' => 'outlook',
'title' => esc_html__( 'Outlook', 'wp-mail-smtp' ),
'disabled' => true,
)
);
}
/**
* @inheritdoc
*/
public function display_options() {
?>
<p>
<?php esc_html_e( 'We\'re sorry, the Microsoft Outlook mailer is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wp-mail-smtp' ); ?>
</p>
<?php
}
}

View File

@ -1,32 +1,32 @@
<?php
namespace WPMailSMTP\Providers\Pepipost;
use WPMailSMTP\Providers\MailerAbstract;
/**
* Class Mailer inherits everything from parent abstract class.
* This file is required for a proper work of Loader and \ReflectionClass.
*
* @package WPMailSMTP\Providers\Pepipost
*/
class Mailer extends MailerAbstract {
/**
* @inheritdoc
*/
public function is_mailer_complete() {
$options = $this->options->get_group( $this->mailer );
// Host and Port are the only really required options.
if (
! empty( $options['host'] ) &&
! empty( $options['port'] )
) {
return true;
}
return false;
}
}
<?php
namespace WPMailSMTP\Providers\Pepipost;
use WPMailSMTP\Providers\MailerAbstract;
/**
* Class Mailer inherits everything from parent abstract class.
* This file is required for a proper work of Loader and \ReflectionClass.
*
* @package WPMailSMTP\Providers\Pepipost
*/
class Mailer extends MailerAbstract {
/**
* @inheritdoc
*/
public function is_mailer_complete() {
$options = $this->options->get_group( $this->mailer );
// Host and Port are the only really required options.
if (
! empty( $options['host'] ) &&
! empty( $options['port'] )
) {
return true;
}
return false;
}
}

View File

@ -1,32 +1,32 @@
<?php
namespace WPMailSMTP\Providers\SMTP;
use WPMailSMTP\Providers\MailerAbstract;
/**
* Class Mailer inherits everything from parent abstract class.
* This file is required for a proper work of Loader and \ReflectionClass.
*
* @package WPMailSMTP\Providers\SMTP
*/
class Mailer extends MailerAbstract {
/**
* @inheritdoc
*/
public function is_mailer_complete() {
$options = $this->options->get_group( $this->mailer );
// Host and Port are the only really required options.
if (
! empty( $options['host'] ) &&
! empty( $options['port'] )
) {
return true;
}
return false;
}
}
<?php
namespace WPMailSMTP\Providers\SMTP;
use WPMailSMTP\Providers\MailerAbstract;
/**
* Class Mailer inherits everything from parent abstract class.
* This file is required for a proper work of Loader and \ReflectionClass.
*
* @package WPMailSMTP\Providers\SMTP
*/
class Mailer extends MailerAbstract {
/**
* @inheritdoc
*/
public function is_mailer_complete() {
$options = $this->options->get_group( $this->mailer );
// Host and Port are the only really required options.
if (
! empty( $options['host'] ) &&
! empty( $options['port'] )
) {
return true;
}
return false;
}
}

View File

@ -1,93 +1,98 @@
<?php
namespace WPMailSMTP\Providers\Sendinblue;
/**
* Class Api is a wrapper for Sendinblue library with handy methods.
*
* @since 1.6.0
*/
class Api {
/**
* Contains mailer options, constants + DB values.
*
* @since 1.6.0
*
* @var array
*/
private $options;
/**
* API constructor that inits defaults and retrieves options.
*
* @since 1.6.0
*/
public function __construct() {
$this->options = \WPMailSMTP\Options::init()->get_group( Options::SLUG );
}
/**
* Configure API key authorization: api-key.
*
* @since 1.6.0
*
* @return \SendinBlue\Client\Configuration
*/
protected function get_api_config() {
return \SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey( 'api-key', isset( $this->options['api_key'] ) ? $this->options['api_key'] : '' );
}
/**
* Get the mailer client instance for Account API.
*
* @since 1.6.0
*/
public function get_account_client() {
// Include the library.
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
return new \SendinBlue\Client\Api\AccountApi( null, $this->get_api_config() );
}
/**
* Get the mailer client instance for Sender API.
*
* @since 1.6.0
*/
public function get_sender_client() {
// Include the library.
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
return new \SendinBlue\Client\Api\SendersApi( null, $this->get_api_config() );
}
/**
* Get the mailer client instance for SMTP API.
*
* @since 1.6.0
*/
public function get_smtp_client() {
// Include the library.
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
return new \SendinBlue\Client\Api\SMTPApi( null, $this->get_api_config() );
}
/**
* Whether the mailer is ready to be used in API calls.
*
* @since 1.6.0
*
* @return bool
*/
public function is_ready() {
return ! empty( $this->options['api_key'] );
}
}
<?php
namespace WPMailSMTP\Providers\Sendinblue;
use WPMailSMTP\Vendor\SendinBlue\Client\Api\AccountApi;
use WPMailSMTP\Vendor\SendinBlue\Client\Api\SendersApi;
use WPMailSMTP\Vendor\SendinBlue\Client\Api\SMTPApi;
use WPMailSMTP\Vendor\SendinBlue\Client\Configuration;
/**
* Class Api is a wrapper for Sendinblue library with handy methods.
*
* @since 1.6.0
*/
class Api {
/**
* Contains mailer options, constants + DB values.
*
* @since 1.6.0
*
* @var array
*/
private $options;
/**
* API constructor that inits defaults and retrieves options.
*
* @since 1.6.0
*/
public function __construct() {
$this->options = \WPMailSMTP\Options::init()->get_group( Options::SLUG );
}
/**
* Configure API key authorization: api-key.
*
* @since 1.6.0
*
* @return Configuration
*/
protected function get_api_config() {
return Configuration::getDefaultConfiguration()->setApiKey( 'api-key', isset( $this->options['api_key'] ) ? $this->options['api_key'] : '' );
}
/**
* Get the mailer client instance for Account API.
*
* @since 1.6.0
*/
public function get_account_client() {
// Include the library.
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
return new AccountApi( null, $this->get_api_config() );
}
/**
* Get the mailer client instance for Sender API.
*
* @since 1.6.0
*/
public function get_sender_client() {
// Include the library.
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
return new SendersApi( null, $this->get_api_config() );
}
/**
* Get the mailer client instance for SMTP API.
*
* @since 1.6.0
*/
public function get_smtp_client() {
// Include the library.
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
return new SMTPApi( null, $this->get_api_config() );
}
/**
* Whether the mailer is ready to be used in API calls.
*
* @since 1.6.0
*
* @return bool
*/
public function is_ready() {
return ! empty( $this->options['api_key'] );
}
}

View File

@ -5,6 +5,9 @@ namespace WPMailSMTP\Providers\Sendinblue;
use WPMailSMTP\Debug;
use WPMailSMTP\MailCatcherInterface;
use WPMailSMTP\Providers\MailerAbstract;
use WPMailSMTP\Vendor\SendinBlue\Client\ApiException;
use WPMailSMTP\Vendor\SendinBlue\Client\Model\CreateSmtpEmail;
use WPMailSMTP\Vendor\SendinBlue\Client\Model\SendSmtpEmail;
use WPMailSMTP\WP;
/**
@ -286,11 +289,11 @@ class Mailer extends MailerAbstract {
*
* @since 1.6.0
*
* @return \SendinBlue\Client\Model\SendSmtpEmail
* @return SendSmtpEmail
*/
public function get_body() {
return new \SendinBlue\Client\Model\SendSmtpEmail( $this->body );
return new SendSmtpEmail( $this->body );
}
/**
@ -306,7 +309,7 @@ class Mailer extends MailerAbstract {
$response = $api->get_smtp_client()->sendTransacEmail( $this->get_body() );
$this->process_response( $response );
} catch ( \SendinBlue\Client\ApiException $e ) {
} catch ( ApiException $e ) {
$error = json_decode( $e->getResponseBody() );
if ( json_last_error() === JSON_ERROR_NONE && ! empty( $error ) ) {
@ -330,7 +333,7 @@ class Mailer extends MailerAbstract {
*
* @since 1.6.0
*
* @param \SendinBlue\Client\Model\CreateSmtpEmail $response
* @param CreateSmtpEmail $response The Sendinblue Email object.
*/
protected function process_response( $response ) {
@ -348,7 +351,7 @@ class Mailer extends MailerAbstract {
$is_sent = false;
if ( $this->response instanceof \SendinBlue\Client\Model\CreateSmtpEmail ) {
if ( $this->response instanceof CreateSmtpEmail ) {
$is_sent = $this->response->valid();
}

View File

@ -27,30 +27,41 @@ class Options extends OptionsAbstract {
*/
public function __construct() {
$description = sprintf(
wp_kses( /* translators: %1$s - URL to sendinblue.com site. */
__( '<strong><a href="%1$s" target="_blank" rel="noopener noreferrer">Sendinblue</a> is our recommended transactional email service.</strong> Founded in 2012, they serve 80,000+ growing companies around the world and send over 30 million emails each day. They understand that transactional emails are the heart of your customer relationships. Their email deliverability experts are constantly at work optimizing the reliability and speed of their SMTP infrastructure. Sendinblue provides users 300 free emails per day.', 'wp-mail-smtp' ) .
'<br><br>' .
/* translators: %2$s - URL to wpmailsmtp.com doc. */
__( 'Read our <a href="%2$s" target="_blank" rel="noopener noreferrer">Sendinblue documentation</a> to learn how to configure Sendinblue and improve your email deliverability.', 'wp-mail-smtp' ),
[
'strong' => true,
'br' => true,
'a' => [
'href' => true,
'rel' => true,
'target' => true,
],
]
),
'https://wpmailsmtp.com/go/sendinblue/',
'https://wpmailsmtp.com/docs/how-to-set-up-the-sendinblue-mailer-in-wp-mail-smtp'
);
$api_key = PluginOptions::init()->get( self::SLUG, 'api_key' );
if ( empty( $api_key ) ) {
$description .= '</p><p class="buttonned"><a href="https://wpmailsmtp.com/go/sendinblue/" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-blueish">' .
esc_html__( 'Get Sendinblue Now (Free)', 'wp-mail-smtp' ) .
'</a></p>';
}
parent::__construct(
[
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/sendinblue.svg',
'slug' => self::SLUG,
'title' => esc_html__( 'Sendinblue', 'wp-mail-smtp' ),
'php' => '5.6',
'description' => sprintf(
wp_kses( /* translators: %1$s - URL to sendinblue.com site. */
__( '<a href="%1$s" target="_blank" rel="noopener noreferrer">Sendinblue</a> serves 80,000+ growing companies around the world and sends over 30 million emails each day. They provide users 300 free emails per day.', 'wp-mail-smtp' ) .
'<br><br>' .
/* translators: %2$s - URL to wpmailsmtp.com doc. */
__( 'Read our <a href="%2$s" target="_blank" rel="noopener noreferrer">Sendinblue documentation</a> to learn how to configure Sendinblue and improve your email deliverability.', 'wp-mail-smtp' ),
[
'br' => true,
'a' => [
'href' => true,
'rel' => true,
'target' => true,
],
]
),
'https://wpmailsmtp.com/go/sendinblue/',
'https://wpmailsmtp.com/docs/how-to-set-up-the-sendinblue-mailer-in-wp-mail-smtp'
),
'description' => $description,
'supports' => [
'from_email' => true,
'from_name' => true,
@ -58,6 +69,7 @@ class Options extends OptionsAbstract {
'from_email_force' => true,
'from_name_force' => true,
],
'recommended' => true,
]
);
}

View File

@ -186,7 +186,7 @@ class Task {
$action_id = null;
// No processing if ActionScheduler is not usable.
if ( ! wp_mail_smtp()->get_tasks()->is_usable() ) {
if ( ! Tasks::is_usable() ) {
return $action_id;
}

View File

@ -27,7 +27,7 @@ class Tasks {
add_action( 'admin_menu', array( $this, 'admin_hide_as_menu' ), PHP_INT_MAX );
// Skip tasks registration if Action Scheduler is not usable yet.
if ( ! $this->is_usable() ) {
if ( ! self::is_usable() ) {
return;
}
@ -126,7 +126,7 @@ class Tasks {
*
* @return bool
*/
public function is_usable() {
public static function is_usable() {
// No tasks if ActionScheduler wasn't loaded.
if ( ! class_exists( 'ActionScheduler_DataController' ) ) {
@ -145,7 +145,7 @@ class Tasks {
*
* @return bool
*/
public function is_scheduled( $hook ) {
public static function is_scheduled( $hook ) {
if ( ! function_exists( 'as_next_scheduled_action' ) ) {
return false;

View File

@ -1,71 +1,71 @@
<?php
namespace WPMailSMTP;
/**
* Class Upgrade helps upgrade plugin options and similar tasks when the
* occasion arises.
*
* @since 1.1.0
*/
class Upgrade {
/**
* Upgrade constructor.
*
* @since 1.1.0
*/
public function __construct() {
$upgrades = $this->upgrades();
if ( empty( $upgrades ) ) {
return;
}
// Run any available upgrades.
foreach ( $upgrades as $upgrade ) {
$this->{$upgrade}();
}
// Update version post upgrade(s).
update_option( 'wp_mail_smtp_version', WPMS_PLUGIN_VER );
}
/**
* Whether we need to perform an upgrade.
*
* @since 1.1.0
*
* @return array
*/
protected function upgrades() {
$version = get_option( 'wp_mail_smtp_version' );
$upgrades = array();
// Version 1.1.0 upgrade; prior to this the option was not available.
if ( empty( $version ) ) {
$upgrades[] = 'v110_upgrade';
}
return $upgrades;
}
/**
* Upgrade routine for v1.1.0.
*
* Set SMTPAutoTLS to true.
*
* @since 1.1.0
*/
public function v110_upgrade() {
$values = Options::init()->get_all();
// Enable SMTPAutoTLS option.
$values['smtp']['autotls'] = true;
Options::init()->set( $values );
}
}
<?php
namespace WPMailSMTP;
/**
* Class Upgrade helps upgrade plugin options and similar tasks when the
* occasion arises.
*
* @since 1.1.0
*/
class Upgrade {
/**
* Upgrade constructor.
*
* @since 1.1.0
*/
public function __construct() {
$upgrades = $this->upgrades();
if ( empty( $upgrades ) ) {
return;
}
// Run any available upgrades.
foreach ( $upgrades as $upgrade ) {
$this->{$upgrade}();
}
// Update version post upgrade(s).
update_option( 'wp_mail_smtp_version', WPMS_PLUGIN_VER );
}
/**
* Whether we need to perform an upgrade.
*
* @since 1.1.0
*
* @return array
*/
protected function upgrades() {
$version = get_option( 'wp_mail_smtp_version' );
$upgrades = array();
// Version 1.1.0 upgrade; prior to this the option was not available.
if ( empty( $version ) ) {
$upgrades[] = 'v110_upgrade';
}
return $upgrades;
}
/**
* Upgrade routine for v1.1.0.
*
* Set SMTPAutoTLS to true.
*
* @since 1.1.0
*/
public function v110_upgrade() {
$values = Options::init()->get_all();
// Enable SMTPAutoTLS option.
$values['smtp']['autotls'] = true;
Options::init()->set( $values );
}
}

View File

@ -25,7 +25,7 @@ class SendUsageTask extends Task {
*
* @var string
*/
const TRACK_URL = 'https://usage.wpmailsmtp.com/v1/smtptrack';
const TRACK_URL = 'https://wpmailsmtpusage.com/v1/smtptrack';
/**
* Class constructor.