updated plugin WP Mail SMTP
version 2.4.0
This commit is contained in:
@ -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'] );
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user