|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Plugin Name: DadsFam SMTP |
| 4 | + * Plugin URI: https://www.dadsfam.co.za/plugins/smtp |
| 5 | + * Description: A premium WordPress SMTP mailer. Supports 13+ providers, email logging, resend, auto-retry, smart routing, Slack alerts, analytics, WooCommerce diagnostics, and full DadsFam license integration. A genuinely competitive alternative to WP Mail SMTP and FluentSMTP. |
| 6 | + * Version: 1.1.8 |
| 7 | + * Requires at least: 6.0 |
| 8 | + * Requires PHP: 8.0 |
| 9 | + * Author: DadsFam |
| 10 | + * Author URI: https://www.dadsfam.co.za |
| 11 | + * License: GPL v2 or later |
| 12 | + * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 | + * Text Domain: dadsfam-smtp |
| 14 | + * Domain Path: /languages |
| 15 | + * |
| 16 | + * ============================================================================= |
| 17 | + * CHANGELOG |
| 18 | + * ============================================================================= |
| 19 | + * |
| 20 | + * v1.1.0 — Feature Expansion & Competitive Parity |
| 21 | + * ------------------------------------------------ |
| 22 | + * FREE ADDITIONS: |
| 23 | + * ADDED: Delivery failure email alerts moved to FREE (was PRO) |
| 24 | + * ADDED: Email log limit increased to 100 entries FREE (was 25) |
| 25 | + * ADDED: Reply-To email address override (global, FREE) |
| 26 | + * ADDED: Resend any logged email with one click (FREE, body stored for all) |
| 27 | + * ADDED: WooCommerce email diagnostics — detect WC + test each email type (FREE) |
| 28 | + * ADDED: Basic 7-day sent/failed stats on Dashboard (FREE) |
| 29 | + * ADDED: Return-Path / Envelope sender setting (FREE) |
| 30 | + * |
| 31 | + * PRO ADDITIONS: |
| 32 | + * ADDED: PRO: Secondary SMTP failover — if primary fails, retry via backup server |
| 33 | + * ADDED: PRO: Smart Email Routing rules — route by From, Subject, or recipient domain |
| 34 | + * ADDED: PRO: Auto-retry failed emails (configurable retry count + delay) |
| 35 | + * ADDED: PRO: Slack / Discord / custom webhook failure notifications |
| 36 | + * ADDED: PRO: Weekly email digest report — summary of delivery stats to admin |
| 37 | + * ADDED: PRO: Analytics page — 7-day sent/failed chart + provider breakdown |
| 38 | + * ADDED: PRO: Global BCC — silently copy every outgoing email |
| 39 | + * ADDED: PRO: CSV log export |
| 40 | + * ADDED: PRO: Open tracking pixel |
| 41 | + * ADDED: PRO: Full email body viewer (HTML sandboxed iframe) |
| 42 | + * ADDED: PRO: Unlimited email logs |
| 43 | + * |
| 44 | + * v1.0.0 — Initial Release (26 May 2026) |
| 45 | + * ---------------------------------------- |
| 46 | + * 13+ pre-configured SMTP providers, AES-256 encryption, logging, test email, |
| 47 | + * connection test, DF License integration with force-lock. |
| 48 | + * ============================================================================= |
| 49 | + */ |
| 50 | + |
| 51 | +if ( ! defined( 'ABSPATH' ) ) { |
| 52 | + exit; |
| 53 | +} |
| 54 | + |
| 55 | +// ── Constants ───────────────────────────────────────────────────────────────── |
| 56 | +define( 'DFSMTP_VERSION', '1.1.8' ); |
| 57 | +define( 'DFSMTP_FILE', __FILE__ ); |
| 58 | +define( 'DFSMTP_DIR', plugin_dir_path( __FILE__ ) ); |
| 59 | +define( 'DFSMTP_URL', plugin_dir_url( __FILE__ ) ); |
| 60 | +define( 'DFSMTP_SLUG', 'dadsfam-smtp' ); |
| 61 | +define( 'DFSMTP_PRODUCT', 'dfsmtp' ); |
| 62 | +define( 'DFSMTP_LM_API', 'https://www.dadsfam.co.za/wp-json/dfem-licenses/v1/verify' ); |
| 63 | + |
| 64 | +// ── Autoload ────────────────────────────────────────────────────────────────── |
| 65 | +require_once DFSMTP_DIR . 'includes/class-dfsmtp-encryption.php'; |
| 66 | +require_once DFSMTP_DIR . 'includes/class-dfsmtp-license.php'; |
| 67 | +require_once DFSMTP_DIR . 'includes/class-dfsmtp-logger.php'; |
| 68 | +require_once DFSMTP_DIR . 'includes/class-dfsmtp-mailer.php'; |
| 69 | +require_once DFSMTP_DIR . 'includes/admin/class-dfsmtp-admin.php'; |
| 70 | + |
| 71 | +// ── Boot ────────────────────────────────────────────────────────────────────── |
| 72 | +add_action( 'plugins_loaded', function () { |
| 73 | + DFSMTP_License::instance(); |
| 74 | + DFSMTP_Mailer::instance(); |
| 75 | + DFSMTP_Logger::instance(); |
| 76 | + if ( is_admin() ) { |
| 77 | + DFSMTP_Admin::instance(); |
| 78 | + } |
| 79 | +} ); |
| 80 | + |
| 81 | +// ── Activation / Deactivation ───────────────────────────────────────────────── |
| 82 | +register_activation_hook( __FILE__, 'dfsmtp_activate' ); |
| 83 | +register_deactivation_hook( __FILE__, 'dfsmtp_deactivate' ); |
| 84 | + |
| 85 | +function dfsmtp_activate(): void { |
| 86 | + DFSMTP_Logger::create_table(); |
| 87 | + |
| 88 | + // Cron schedules |
| 89 | + if ( ! wp_next_scheduled( 'dfsmtp_hourly_verify' ) ) { |
| 90 | + wp_schedule_event( time(), 'hourly', 'dfsmtp_hourly_verify' ); |
| 91 | + } |
| 92 | + if ( ! wp_next_scheduled( 'dfsmtp_retry_failed' ) ) { |
| 93 | + wp_schedule_event( time(), 'dfsmtp_five_min', 'dfsmtp_retry_failed' ); |
| 94 | + } |
| 95 | + if ( ! wp_next_scheduled( 'dfsmtp_weekly_digest' ) ) { |
| 96 | + wp_schedule_event( strtotime('next monday 08:00'), 'weekly', 'dfsmtp_weekly_digest' ); |
| 97 | + } |
| 98 | + |
| 99 | + // Default options (only set on first activation) |
| 100 | + if ( ! get_option( 'dfsmtp_settings' ) ) { |
| 101 | + update_option( 'dfsmtp_settings', [ |
| 102 | + 'provider' => 'smtp', |
| 103 | + 'host' => '', |
| 104 | + 'port' => 587, |
| 105 | + 'encryption' => 'tls', |
| 106 | + 'auth' => true, |
| 107 | + 'username' => '', |
| 108 | + 'password' => '', |
| 109 | + 'from_name' => get_bloginfo( 'name' ), |
| 110 | + 'from_email' => get_bloginfo( 'admin_email' ), |
| 111 | + 'reply_to' => '', |
| 112 | + 'return_path' => '', |
| 113 | + 'log_enabled' => true, |
| 114 | + 'failure_alert' => true, |
| 115 | + 'weekly_digest' => false, |
| 116 | + ] ); |
| 117 | + } |
| 118 | +} |
| 119 | + |
| 120 | +function dfsmtp_deactivate(): void { |
| 121 | + wp_clear_scheduled_hook( 'dfsmtp_hourly_verify' ); |
| 122 | + wp_clear_scheduled_hook( 'dfsmtp_retry_failed' ); |
| 123 | + wp_clear_scheduled_hook( 'dfsmtp_weekly_digest' ); |
| 124 | +} |
| 125 | + |
| 126 | +// ── Custom cron intervals ───────────────────────────────────────────────────── |
| 127 | +add_filter( 'cron_schedules', function ( $s ) { |
| 128 | + $s['dfsmtp_five_min'] = [ 'interval' => 300, 'display' => 'Every 5 Minutes (DadsFam SMTP)' ]; |
| 129 | + $s['weekly'] = [ 'interval' => 604800, 'display' => 'Once Weekly' ]; |
| 130 | + return $s; |
| 131 | +} ); |
| 132 | + |
| 133 | +// ── Text domain ─────────────────────────────────────────────────────────────── |
| 134 | +add_action( 'init', function () { |
| 135 | + load_plugin_textdomain( 'dadsfam-smtp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 136 | +} ); |
0 commit comments