From ed2cc2f70aa1f0144e623c95ed5abebfa910f200 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 18 Feb 2026 16:04:13 +0000 Subject: [PATCH] v2.2.3 --- changelog.txt | 6 +++ includes/class-plugin.php | 76 ++++++++++++++++++++++++++++++++++- readme.txt | 10 ++++- robotstxt-smtp-newsletter.php | 4 +- update.json | 10 ++--- 5 files changed, 96 insertions(+), 10 deletions(-) diff --git a/changelog.txt b/changelog.txt index b49f2d2..d9c7fa2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ += 2.2.3 = + +* CRITICAL FIX: Overridden get_emails_per_run() to bypass Newsletter's internal calculation +* FIXED: Newsletter was calculating batch = speed / 12, resulting in only 8-16 emails per execution +* FIXED: Plugin now directly returns configured batch_size for proper queue loading + = 2.2.2 = * FIXED: Newsletter now correctly respects configured batch_size when enqueuing emails diff --git a/includes/class-plugin.php b/includes/class-plugin.php index caf1a71..406a102 100644 --- a/includes/class-plugin.php +++ b/includes/class-plugin.php @@ -126,6 +126,9 @@ class Plugin extends \NewsletterMailerAddon { // Load text domain. add_action( 'init', array( $this, 'load_textdomain' ) ); + // Force batch size in Newsletter cron. + add_filter( 'newsletter_max_emails', array( $this, 'filter_max_emails' ), 999 ); + // Register admin pages. if ( is_admin() ) { require_once ROBOTSTXT_SMTP_NEWSLETTER_PATH . 'admin/class-settings-page.php'; @@ -138,6 +141,25 @@ class Plugin extends \NewsletterMailerAddon { } } + /** + * Filter Newsletter's max emails per execution. + * + * Forces Newsletter to use our configured batch_size. + * + * @param int $max_emails Newsletter's calculated max emails. + * + * @return int Our configured batch_size. + */ + public function filter_max_emails( $max_emails ) { + // Only apply if our addon is enabled. + $settings = $this->get_settings(); + if ( empty( $settings['enabled'] ) ) { + return $max_emails; + } + + return absint( $settings['batch_size'] ?? 10 ); + } + /** * Load plugin text domain for translations. * @@ -172,10 +194,19 @@ class Plugin extends \NewsletterMailerAddon { // Calculate optimal speed (emails per hour) based on rate limits. $speed = $this->calculate_optimal_speed( $smtp_settings ); + // CRITICAL: For queue-based architecture, speed must be high enough + // that Newsletter loads all emails at once. Newsletter calculates + // batch_size = speed / (60 / cron_interval). With default 5-minute cron: + // batch_size = speed / 12. To get batch_size = configured value, + // we need: speed = batch_size * 12. + $batch_size = $settings['batch_size'] ?? 10; + $speed_multiplier = 12; // Assumes 5-minute cron (12 executions per hour). + $calculated_speed = max( $speed, $batch_size * $speed_multiplier ); + // Newsletter expects 'turbo' for batch_size and 'speed' for emails/hour. $mailer_options = array( - 'turbo' => $settings['batch_size'] ?? 10, - 'speed' => $speed, + 'turbo' => $batch_size, + 'speed' => $calculated_speed, ); // Detect if Amazon SES is active. @@ -188,6 +219,47 @@ class Plugin extends \NewsletterMailerAddon { } } + /** + * Get maximum emails per execution. + * + * Newsletter checks this method to determine batch size. + * + * @return int + */ + public function get_max_emails() { + $settings = $this->get_settings(); + return absint( $settings['batch_size'] ?? 10 ); + } + + /** + * Get batch size. + * + * Alternative method that Newsletter may check. + * + * @return int + */ + public function get_batch() { + return $this->get_max_emails(); + } + + /** + * Override Newsletter's calculation of emails per run. + * + * Newsletter normally calculates: batch = speed / runs_per_hour + * For queue-based architecture, we want to enqueue all emails at once. + * + * @return int Configured batch_size. + */ + public function get_emails_per_run() { + $settings = $this->get_settings(); + if ( empty( $settings['enabled'] ) ) { + // If addon is disabled, use parent's calculation. + return parent::get_emails_per_run(); + } + + return absint( $settings['batch_size'] ?? 10 ); + } + /** * Calculate optimal speed (emails per hour) based on rate limits. * diff --git a/readme.txt b/readme.txt index 8af6fc1..5ad8569 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: newsletter, smtp, email, bulk, queue, worker, amazonses, statistics Requires at least: 4.7 Tested up to: 6.9 Requires PHP: 7.2 -Stable tag: 2.2.2 +Stable tag: 2.2.3 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -141,6 +141,11 @@ Yes. The plugin integrates with ROBOTSTXT SMTP rate limiting system to ensure yo == Changelog == += 2.2.3 = +* CRITICAL FIX: Overridden get_emails_per_run() to bypass Newsletter's internal calculation +* FIXED: Newsletter was calculating batch = speed / 12, resulting in only 8-16 emails per execution +* FIXED: Plugin now directly returns configured batch_size for proper queue loading + = 2.2.2 = * FIXED: Newsletter now correctly respects configured batch_size when enqueuing emails * FIXED: Emails are now enqueued all at once to database instead of gradually @@ -180,6 +185,9 @@ Yes. The plugin integrates with ROBOTSTXT SMTP rate limiting system to ensure yo == Upgrade Notice == += 2.2.3 = +CRITICAL: Fixed Newsletter loading only 8-16 emails per execution. Now correctly loads all emails based on configured batch_size. + = 2.2.2 = Fixed batch size enforcement - emails now enqueue correctly all at once instead of gradually. diff --git a/robotstxt-smtp-newsletter.php b/robotstxt-smtp-newsletter.php index 4b47c2e..949ee33 100644 --- a/robotstxt-smtp-newsletter.php +++ b/robotstxt-smtp-newsletter.php @@ -3,7 +3,7 @@ * Plugin Name: Newsletter - SMTP (by ROBOTSTXT) * Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp-newsletter * Description: Integrates ROBOTSTXT SMTP configuration with Newsletter plugin for efficient bulk email delivery with database-backed queue and external workers. - * Version: 2.2.2 + * Version: 2.2.3 * Requires at least: 4.7 * Requires PHP: 7.2 * Security: robotstxt@robotstxt.es @@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) { } // Plugin constants. -define( 'ROBOTSTXT_SMTP_NEWSLETTER_VERSION', '2.2.2' ); +define( 'ROBOTSTXT_SMTP_NEWSLETTER_VERSION', '2.2.3' ); define( 'ROBOTSTXT_SMTP_NEWSLETTER_FILE', __FILE__ ); define( 'ROBOTSTXT_SMTP_NEWSLETTER_PATH', plugin_dir_path( __FILE__ ) ); define( 'ROBOTSTXT_SMTP_NEWSLETTER_URL', plugin_dir_url( __FILE__ ) ); diff --git a/update.json b/update.json index ad0107c..a1423ce 100644 --- a/update.json +++ b/update.json @@ -1,19 +1,19 @@ { "name": "Newsletter - SMTP (by ROBOTSTXT)", "slug": "robotstxt-smtp-newsletter", - "version": "2.2.2", + "version": "2.2.3", "author": "ROBOTSTXT", "homepage": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp-newsletter", - "download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp-newsletter/releases/download/2.2.2/robotstxt-smtp-newsletter-2.2.2.zip", + "download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp-newsletter/releases/download/2.2.3/robotstxt-smtp-newsletter-2.2.3.zip", "requires": "4.7", "tested": "6.9", "requires_php": "7.2", "last_updated": "2026-02-16", "description": "Integrates ROBOTSTXT SMTP configuration with Newsletter plugin for reliable bulk email delivery with database-backed queue and external workers. Provides persistent email queue, parallel processing, automatic retry, and comprehensive campaign statistics.", - "changelog": "

2.2.2 - 2026-02-16

2.2.1 - 2026-02-16

2.2.0 - 2026-02-16

2.1.0 - 2026-02-09

2.0.1 - 2026-01-29

2.0.0 - 2026-01-29

1.0.0 - 2026-01-29

", + "changelog": "

2.2.3 - 2026-02-16

2.2.2 - 2026-02-16

2.2.1 - 2026-02-16

2.2.0 - 2026-02-16

2.1.0 - 2026-02-09

2.0.1 - 2026-01-29

2.0.0 - 2026-01-29

1.0.0 - 2026-01-29

", "sections": { - "description": "Integrates ROBOTSTXT SMTP configuration with Newsletter plugin for reliable bulk email delivery with database-backed queue and external workers. Version 2.2.2 fixes batch size enforcement to ensure all emails are enqueued at once. Emails are queued to database and processed by external CLI workers, providing reliability, scalability, and detailed monitoring.", - "changelog": "

2.2.2 - 2026-02-16

2.2.1 - 2026-02-16

2.2.0 - 2026-02-16

" + "description": "Integrates ROBOTSTXT SMTP configuration with Newsletter plugin for reliable bulk email delivery with database-backed queue and external workers. Version 2.2.3 fixes critical batch loading issue where Newsletter was only loading 8-16 emails per execution. Emails are queued to database and processed by external CLI workers, providing reliability, scalability, and detailed monitoring.", + "changelog": "

2.2.3 - 2026-02-16

2.2.2 - 2026-02-16

2.2.1 - 2026-02-16

2.2.0 - 2026-02-16

" }, "banners": { "low": "",