Файловый менеджер - Редактировать - /home/bean7936/perfect-community.com/442aa3/newsletter-smtp.zip
Назад
PK ���\�L�3Q Q smtp.phpnu �[��� <?php /* Plugin Name: Newsletter - SMTP Delivery Addon Plugin URI: https://www.thenewsletterplugin.com/documentation/addons/delivery-addons/smtp-extension/ Description: Enable the use of an SMTP to send newsletters Version: 1.2.5 Requires at least: 6.1 Requires PHP: 7.0 Author: The Newsletter Team Author URI: https://www.thenewsletterplugin.com Disclaimer: Use at your own risk. No warranty expressed or implied is provided. */ defined('ABSPATH') || exit; add_action('newsletter_loaded', function ($version) { global $wp_version; if (version_compare($wp_version, '5.5') < 0) { echo '<div class="notice notice-error"><p>WP 5.5+ required by <strong>Newsletter - SMTP Addon</strong>.</p></div>'; } elseif (version_compare($version, '9.0.0', '<')) { add_action('admin_notices', function () { echo '<div class="notice notice-error"><p>Newsletter plugin upgrade required by <strong>Newsletter - SMTP Addon</strong>.</p></div>'; }); } else { require_once __DIR__ . '/plugin.php'; new NewsletterSmtp('1.2.5'); } }); PK ���\�1A�� � classes/mailer.phpnu �[��� <?php class NewsletterSmtpMailer extends NewsletterMailer { /** * @var \PHPMailer\PHPMailer\PHPMailer */ var $mailer; function __construct($options) { parent::__construct('smtp', $options); } function get_description() { return 'SMTP Addon'; } public function send($message) { $logger = $this->get_logger(); $logger->debug('Start sending to ' . $message->to); $mailer = $this->get_mailer(); if (!empty($message->body)) { $mailer->IsHTML(true); $mailer->Body = $message->body; $mailer->AltBody = $message->body_text; } else { $mailer->IsHTML(false); $mailer->Body = $message->body_text; $mailer->AltBody = ''; } $mailer->Subject = $message->subject; $mailer->ClearCustomHeaders(); if (!empty($message->headers)) { foreach ($message->headers as $key => $value) { $mailer->AddCustomHeader($key, $value); } } if ($message->from) { //$logger->debug('Alternative from available'); $mailer->setFrom($message->from, $message->from_name); } else { $newsletter = Newsletter::instance(); $mailer->setFrom($newsletter->options['sender_email'], $newsletter->options['sender_name']); } $mailer->ClearAddresses(); $mailer->AddAddress($message->to); $mailer->Send(); if ($mailer->IsError()) { $logger->fatal($mailer->ErrorInfo); // If the error is due to SMTP connection, the mailer cannot be reused since it does not clean up the connection // on error. //$this->mailer = null; $message->error = $mailer->ErrorInfo; if (empty($this->options['continue_on_error'])) { $error_type = self::ERROR_FATAL; // Specific email error, not service error if (stripos($mailer->ErrorInfo, 'The following recipients failed') !== false) { $error_type = self::ERROR_GENERIC; } return new WP_Error($error_type, $mailer->ErrorInfo); } else { return new WP_Error(self::ERROR_GENERIC, $mailer->ErrorInfo); } } $logger->debug('Sent ' . $message->to); //$logger->error('Time: ' . (microtime(true) - $start) . ' seconds'); return true; } /** * * @return PHPMailer */ function get_mailer() { global $wp_version; if ($this->mailer) { return $this->mailer; } $logger = $this->get_logger(); $logger->info('Setting up PHP mailer'); if (!class_exists('PHPMailer')) { require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php'; require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; require_once ABSPATH . WPINC . '/PHPMailer/Exception.php'; class_alias(\PHPMailer\PHPMailer\PHPMailer::class, 'PHPMailer'); class_alias(\PHPMailer\PHPMailer\SMTP::class, 'SMTP'); class_alias(\PHPMailer\PHPMailer\Exception::class, 'phpmailerException'); } $this->mailer = new \PHPMailer(false); $this->mailer->XMailer = ' '; // A space! $this->mailer->IsSMTP(); $this->mailer->Host = $this->options['host']; if (!empty($this->options['port'])) { $this->mailer->Port = (int) $this->options['port']; } if (!empty($this->options['user'])) { $this->mailer->SMTPAuth = true; $this->mailer->Username = $this->options['user']; $this->mailer->Password = $this->options['pass']; } $this->mailer->SMTPSecure = $this->options['secure']; $this->mailer->SMTPAutoTLS = false; if ($this->options['ssl_insecure'] == 1) { $this->mailer->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); } $newsletter = Newsletter::instance(); $this->mailer->CharSet = 'UTF-8'; $this->mailer->From = $newsletter->options['sender_email']; if (!empty($newsletter->options['return_path'])) { $this->mailer->Sender = $newsletter->options['return_path']; } if (!empty($newsletter->options['reply_to'])) { $this->mailer->AddReplyTo($newsletter->options['reply_to']); } $this->mailer->FromName = $newsletter->options['sender_name']; return $this->mailer; } } PK ���\~�9� � admin/index.phpnu �[��� <?php /* @var $this NewsletterSmtp */ defined('ABSPATH') || exit; include_once NEWSLETTER_INCLUDES_DIR . '/controls.php'; $controls = new NewsletterControls(); if (!$controls->is_action()) { $controls->data = $this->options; } else { if ($controls->is_action('save') || $controls->is_action('test')) { $controls->data = array_map('trim', $controls->data); if (isset($controls->data['enabled']) && empty($controls->data['host'])) { $controls->errors = 'The host must be set to enable the SMTP'; } if (empty($controls->errors)) { $this->save_options($controls->data); $controls->add_toast_saved(); } if ($controls->is_action('test')) { $mailer = $this->get_mailer(); $message = $this->get_test_message($controls->data['test_email']); $result = $mailer->send_with_stats($message); if (is_wp_error($result)) { $e = $result->get_error_message(); $controls->errors = $e; if (stripos($e, 'Connection timed out')) { $controls->errors .= '<br><br><strong>Probably the hosting provider is blocking the connection to your SMTP server, please contact its support.</strong><br>'; } elseif (stripos($e, 'SMTP connect() failed') !== false) { $controls->errors .= '<br><br><strong>Please check the host and port and try other port/secure combination. Could be the hosting provider is blocking the connection: please contact its support.</strong><br>'; } $controls->errors .= '<br><a href="https://www.thenewsletterplugin.com/documentation/?p=15170" target="_blank"><strong>' . __('Read more', 'newsletter') . '</strong></a>.'; } else { $controls->messages = 'Success.'; $controls->messages .= '<br>Max speed: ' . $mailer->get_capability() . ' emails per hour'; } } } } ?> <div class="wrap" id="tnp-wrap"> <?php include NEWSLETTER_ADMIN_HEADER; ?> <div id="tnp-heading"> <?php include __DIR__ . '/nav.php'; ?> </div> <div id="tnp-body"> <?php $controls->show(); ?> <form method="post" action=""> <?php $controls->init(); ?> <div id="tabs"> <ul> <li><a href="#tabs-general">General</a></li> <li><a href="#tabs-3">Bounces</a></li> </ul> <div id="tabs-general"> <table class="form-table"> <tr> <th>Enable the SMTP?</th> <td><?php $controls->enabled(); ?></td> </tr> <tr> <th>SMTP host/port</th> <td> host: <?php $controls->text('host', 30); ?> port: <?php $controls->text('port', 6, '25'); ?> <?php $controls->select('secure', array('' => 'No secure protocol', 'tls' => 'SMTP+STARTTLS', 'ssl' => 'SMTPS')); ?> </td> </tr> <tr> <th>Authentication</th> <td> user: <?php $controls->text('user', 30); ?> password: <?php $controls->password('pass', 30); ?> </td> </tr> <tr valign="top"> <th>Max mails per hour</th> <td> <?php $controls->text('speed'); ?> <p class="description"> Leave empty to use Newsletter main setting. </p> </td> </tr> <tr> <th> Insecure SSL Connections <?php $controls->field_help('https://www.thenewsletterplugin.com/documentation/addons/delivery-addons/smtp-extension/#ssl') ?> </th> <td> <?php $controls->yesno('ssl_insecure'); ?> </td> </tr> <tr> <th> Continue newsletter sending on errors </th> <td> <?php $controls->yesno('continue_on_error'); ?> </td> </tr> <tr> <th>Test email address</th> <td> <?php $controls->text_email('test_email', 30); ?> <?php $controls->btn('test', 'Save and send test email', ['secondary' => true]); ?> <p class="description"> If the test reports a "connection failed", review your settings and, if correct, contact your provider to unlock the connection (if possible). </p> </td> </tr> </table> </div> <div id="tabs-3"> <p> This addon cannot manage the bounces produced by the connected SMTP server. You can consider to install and configure the <a href="https://www.thenewsletterplugin.com/documentation/addons/extended-features/bounce-extension/" target="_blank">Bounce Addon</a>. </p> <p style="font-weight: bold"> Anyway we advise to use a professional delivery service. Check out our <a href="https://www.thenewsletterplugin.com/documentation/addons/delivery-addons/" target="_blank">integrations</a> (some of them are free, see the addons manager page on the left side menu). </p> </div> </div> <p> <?php $controls->button_save(); ?> </p> </form> </div> </div> PK ���\Ǘ�r� � admin/logs.phpnu �[��� <?php /* @var $this NewsletterMailerAddon */ defined('ABSPATH') || exit; ?> <div class="wrap" id="tnp-wrap"> <?php include NEWSLETTER_ADMIN_HEADER; ?> <div id="tnp-heading"> <?php include __DIR__ . '/nav.php'; ?> </div> <div id="tnp-body"> <form method="post" action=""> <?php $controls->init(); ?> <?php $controls->logs($this->name, ['status' => false]); ?> </form> </div> </div> PK ���\o(�Њ � admin/nav.phpnu �[��� <?php /* @var $this NewsletterMailerAddon */ $p = sanitize_key(wp_unslash($_GET['page'] ?? '')); // To prevent to trigger security analysis, but not necessary ?> <?php $controls->title_help('/addons/delivery-addons/') ?> <ul class="tnp-nav"> <li class="tnp-nav-title"><?php echo esc_html($this->menu_title); ?></li> <li class="<?php echo $p === $this->index_page ? 'active' : '' ?>"><a href="?page=<?php echo $this->index_page; ?>"><?php esc_html_e('Settings', 'newsletter') ?></a></li> <?php if ($this->logs_page) { ?> <li class="<?php echo $p === $this->logs_page ? 'active' : '' ?>"><a href="?page=<?php echo $this->logs_page; ?>"><?php esc_html_e('Logs', 'newsletter') ?></a></li> <?php } ?> <?php if ($this->enabled) { ?> <li class="tnp-nav-badge green">Enabled</li> <?php } else { ?> <li class="tnp-nav-badge orange">Disabled</li> <?php } ?> </ul> PK ���\nS��W W plugin.phpnu �[��� <?php defined('ABSPATH') || exit; class NewsletterSmtp extends NewsletterMailerAddon { /** * @var NewsletterSmtp */ static $instance; public function __construct($version) { self::$instance = $this; $this->menu_title = 'SMTP'; parent::__construct('smtp', $version, __DIR__); } function init() { parent::init(); if (is_admin()) { $this->logs_page = false; } } function weekly_check() { global $wp_version; parent::weekly_check(); $license_key = Newsletter::instance()->get_license_key(); $response = wp_remote_post('https://www.thenewsletterplugin.com/wp-content/addon-check.php?k=' . rawurlencode($license_key) . '&a=' . rawurlencode($this->name) . '&d=' . rawurlencode(home_url()) . '&v=' . rawurlencode($this->version) . '&ml=' . (Newsletter::instance()->is_multilanguage() ? '1' : '0') . '&n=' . rawurlencode(NEWSLETTER_VERSION) . '&w=' . rawurlencode($wp_version) . '&p=' . rawurlencode(PHP_VERSION)); } public function get_mailer() { static $mailer = null; if (!$mailer) { require_once __DIR__ . '/classes/mailer.php'; $mailer = new NewsletterSmtpMailer($this->options); } return $mailer; } } PK ���\�J J readme.txtnu �[��� === SMTP Addon for Newsletter === Tested up to: 6.9.1 Add the external SMTP delivery option. == Description == Using an external SMTP can boost the delivery reliability. This addon connects Newsletter with an external SMTP (from your hosting provider or a professional SMTP service). It is anyway recommended to use an SMTP plugin to connect the whole blog to your chosen service. It is compatibile with the obsolete internal SMTP configuration and on first install it gets the original configuration. == Changelog == = 1.2.5 = * WP 6.9.1 check * Removed legacy WP 5.5 code = 1.2.4 = * WP 6.8.2 check = 1.2.3 = * Added (experimental) check to distinguish generic and fatal errors = 1.2.2 = * Added option to stop on fatal errors = 1.2.1 = * Added fatal error logging * WP 6.8.2 check = 1.2.0 = * Fixed help link = 1.1.9 = * Top menu changes = 1.1.8 = * WP 6.8.1 check = 1.1.7 = * Fixed fata error on error reporting = 1.1.6 = * Improved error checking * Optimized ocde loading * WP 6.7.2 check = 1.1.5 = * WP 6.7.1 check = 1.1.4 = * WP 6.6.2 check = 1.1.3 = * WP 6.6 check = 1.1.2 = * Checked compatibility with WP 6.5.3 * Code review = 1.1.1 = * Checked compatibility with WP 6.5.3 = 1.1.0 = * Checked compatibility with WP 6.4.3 * Aligned with Newsletter 8.1.2 * Removed obsolete migration code * Fixed menu double entry = 1.0.9 = * Checked compatibility with WP 6.3 = 1.0.8 = * Changed protocol labels = 1.0.7 = * Checked compatibility with WP 6.2.2 = 1.0.6 = * Embedded mailer instantiation = 1.0.5 = * Added more information about errors during tests = 1.0.4 = * Checked compatibility with WP 6.1.1 = 1.0.3 = * Checked compatibility with WP 6.0.1 = 1.0.2 = * Checked compatibility with WP 5.9.3 * Removed unused activation hook = 1.0.1 = * Checked compatibility with WP 5.8.3 = 1.0.0 = * First release PK ���\�L�3Q Q smtp.phpnu �[��� PK ���\�1A�� � � classes/mailer.phpnu �[��� PK ���\~�9� � t admin/index.phpnu �[��� PK ���\Ǘ�r� � �1 admin/logs.phpnu �[��� PK ���\o(�Њ � �3 admin/nav.phpnu �[��� PK ���\nS��W W c7 plugin.phpnu �[��� PK ���\�J J �<