FluentSMTP

repository·master·Indexed 41 days ago

https://github.com/wpmanageninja/fluent-smtp

A WordPress plugin designed to improve email deliverability by connecting WordPress Mail to various Email Service Providers (ESPs) via native integrations. It supports multiple connections, automatic email routing, and real-time monitoring. Native integrations include Amazon SES, Gmail, Google Workspace, Outlook, SendGrid, Mailgun, and others.

Tokens
8K
Snippets
15
Records
35
Agent score
51%

What's inside FluentSMTP

  1. Understand the FluentSMTP UI/UX Redesign Plan

    master

    The FluentSMTP UI/UX redesign aims to bring the WordPress admin interface into alignment with the shared Fluent design system (used by FluentCart and FluentAuth).

    Key Changes:

    • Tech Stack Upgrade: Migrating from Vue 2 + Element UI 2 + Laravel Mix to Vue 3 + Element Plus + Tailwind 3 + Vite.
    • Design System: Implementing shared tokens for colors, spacing, radii, and fonts to ensure visual consistency across Fluent products.
    • Information Architecture: Moving from a legacy layout to a fixed top app bar for destinations, with all configuration moved behind a Settings sidebar.
    • Theme Support: Native support for both light and dark modes using CSS variables.

    Important Constraints:

    • No API Changes: The request layer remains on admin-ajax.php using window.FluentMail.$get/$post. Endpoint names, payloads, and nonces are preserved.
    • No Feature Changes: The redesign focuses on skin and IA, not new capabilities.
    • Menu Location: The plugin remains at Settings → FluentSMTP (options-general.php?page=fluent-mail).
  2. Target Information Architecture and Routing

    master

    The redesigned FluentSMTP UI moves from a flat horizontal menu to a top bar with a settings sidebar.

    Top Bar Destinations:

    • Dashboard
    • Email Logs
    • Settings

    Top Bar Actions (Right-hand):

    • Send Test Email: Primary action button.
    • Documentation: Link to /documentation.
    • Theme Switch: Dark/Light mode toggle.

    Settings Sidebar (260px): All configuration items are grouped in the sidebar. Crucially, path values must remain unchanged to prevent breaking external links (e.g., Slack OAuth flows).

    Sidebar ItemRoute Path
    Connections/connections or /connection
    General/connections
    Alerts & Notifications/notification-settings
    Email Test/test
    About/support

    Implementation Note: Set meta.active on each route so the top bar can highlight the 'Settings' destination while any child route in the sidebar is active.

  3. Configure the FluentSMTP Semantic Theme Layer (--fsm-*)

    master

    FluentSMTP uses the --fsm- prefix for semantic CSS variables. Create resources/admin/styles/_theme.scss to define two-value (light/dark) structures for all UI chrome.

    Variable Groups:

    • Surfaces: --fsm-body-bg, --fsm-surface, --fsm-surface-sunk, --fsm-surface-raised
    • Borders: --fsm-border, --fsm-border-strong
    • Text: --fsm-heading, --fsm-text, --fsm-text-mid, --fsm-text-light, --fsm-link
    • Accent: --fsm-accent, --fsm-accent-contrast, --fsm-accent-wash
    • Shadows: --fsm-card-line, --fsm-shadow-card, --fsm-shadow-lift, --fsm-shadow-pop
    • Status: --fsm-{danger,warning,success}-{wash,bg,line,fg}, --fsm-neutral-{bg,fg}

    Scoping: To ensure Element Plus components (which teleport to <body>) inherit these styles, scope the selectors to the <body> tag using the specific WordPress settings page class:

    body.settings_page_fluent-mail { /* light tokens */ }
    
    .fluent_theme_dark body.settings_page_fluent-mail, 
    body.settings_page_fluent-mail.fluent_theme_dark { /* dark tokens */ }
    /* Example semantic variable structure */
    body.settings_page_fluent-mail {
      --fsm-body-bg: #F3F5FA;
      --fsm-surface: #FFFFFF;
      /* ... */
    }
    
    .fluent_theme_dark body.settings_page_fluent-mail {
      --fsm-body-bg: #11171D;
      --fsm-surface: #1C2732;
      /* ... */
    }
  4. How FluentSMTP handles email routing

    master

    FluentSMTP works by replacing the standard WordPress wp_mail() function. It intercepts every email sent by any plugin or theme and routes it through your chosen service.

    Key Routing Features:

    • API-First: Whenever possible, FluentSMTP uses the provider's native API (like Amazon SES API or Gmail OAuth API) instead of SMTP for faster and more reliable delivery.
    • Multi-Connection Routing: You can connect multiple email services. FluentSMTP routes emails to specific providers based on the From address. For example, you can route transactional emails through Amazon SES and marketing emails through SendGrid.
    • Fallback Connections: You can configure a fallback connection that automatically takes over if your primary connection fails.
  5. Understand the FluentSMTP UI/UX Redesign Architecture

    master

    The FluentSMTP admin interface has undergone a major architectural shift from Vue 2/Element UI to Vue 3/Element Plus.

    Key architectural decisions include:

    • Options API: The project uses the Vue 3 Options API throughout instead of <script setup> or the Composition API. This was done to maintain compatibility with existing mixins and helpers (like $get, $post, $t, and ucFirst) that are attached to the component instance.
    • Global Helpers: Helpers are provided via an app.mixin lever, ensuring that component script blocks do not need to change how they access core functionality.
    • Asset Loading: The build process uses two separate Vite builds (boot and app) to handle different script requirements (e.g., plain <script> tags for the admin menu vs. modern modules for the app).
    • Styling: The design system uses a tokenized approach with Tailwind CSS and PostCSS. Component styles are extracted into a single stylesheet to ensure proper loading order and CSS cascade behavior.
  6. Preserve Hash Routes for Backward Compatibility

    master

    FluentSMTP uses hash routes that are embedded in external notifications (Slack, Telegram, Discord) and OAuth redirect URLs. Changing or removing these paths will break existing user workflows and integrations.

    Non-negotiable Rule: All 8 route path values defined in resources/admin/routes.js must remain byte-identical.

    Critical Routes to Protect:

    • #/
    • #/connections (Used by the admin bar node)
    • #/notification-settings (Used for Slack OAuth round trips)
    • #/logs?… (Used in automated alerts)

    Verification: Use tests/lint/browser-route-coverage.php to ensure routes.js and tests/browser/admin-screen-smoke.mjs stay in sync. The build will fail if paths are added or removed inconsistently.

    options-general.php?page=fluent-mail#/logs?per_page=10&page=1&status=failed&search=…
  7. Redesign Component Specifications by Screen

    master

    The redesign replaces legacy Element UI patterns with a new design system based on tokens and specific layout patterns.

    Dashboard

    • Layout: Uses a minmax(0,1fr) 380px grid.
    • Stats: Headline numbers (Sent, Failed, Active Connections, Active Senders) must use stat tiles with the --fsm-tile-* token ramp.
    • Quick Overview: Uses .fsm_aside_block (dashed-rule separated subjects) instead of floated lists.

    Email Logs

    • Status Display: Replace full-row background tinting (e.g., .row_type_failed) with the .fls_tag pattern (one-word status chips: is_success, is_failed, is_blocked, or is_neutral).
    • Table Style: Drop border from el-table; the table should sit flush inside its card container.

    Connections

    • Layout: Use the card + flush-table pattern.
    • Icons: Replace size="mini" icon buttons with Element Plus icon components at size="small".
    • Header: Replace inline-styled float headers with .fsm_card_head.

    Connection Wizard

    • Provider Picker: Replace hardcoded SCSS color overrides (e.g., .con_gmail) with a single token-based selected state rule.
    • Provider Partials: Convert el-form-item stacks to use the .fsm_row pattern (label + description on the left, control pinned to the right).
  8. Configure Vite for FluentSMTP assets and plugins

    master

    The Vite configuration should use vite-plugin-static-copy to move images and libraries into the assets directory and utilize unplugin-vue-components and unplugin-auto-import with ElementPlusResolver to handle Element Plus components automatically.

    Note: For imperative components like el-notification, el-loading, or el-message-box, you must still import their CSS manually in your app.scss.

    import { defineConfig } from 'vite';
    import vue from '@vitejs/plugin-vue';
    import { viteStaticCopy } from 'vite-plugin-static-copy';
    import path from 'path';
    
    export default defineConfig({
        base: '',
        plugins: [
            vue(),
            viteStaticCopy({
                targets: [
                    { src: 'resources/images', dest: '' },
                    { src: 'resources/libs',   dest: '' },
                ]
            }),
        ],
        css: { preprocessorOptions: { scss: { api: 'modern' } } },
        resolve: { alias: { '@': path.resolve(__dirname, 'resources/admin') } },
        // ... build config
    });
  9. Migrate build system from Laravel Mix to Vite

    master

    To maintain compatibility with existing PHP enqueue handlers (fluentMailMix()) and asset URLs, the Vite build must reproduce the exact output file paths used by the previous Laravel Mix setup.

    Required Output Paths:

    • assets/admin/js/boot.js
    • assets/admin/js/fluent-mail-admin-app.js
    • assets/admin/css/fluent-mail-admin.css
    • assets/images/... (copied from resources/images)
    • assets/libs/... (copied from resources/libs)

    Key Constraints:

    • Do not use dynamic imports: Avoid code splitting to prevent the need for a manifest-to-PHP bridge. The app should be a single bundle.
    • Asset Naming: Use rollupOptions.output to ensure entryFileNames and assetFileNames do not include hashes, preserving the hard-coded PHP paths.
    // vite.config.mjs snippet for path preservation
    export default defineConfig({
        build: {
            outDir: 'assets',
            emptyOutDir: true,
            manifest: false,
            cssCodeSplit: false,
            rollupOptions: {
                input: {
                    'admin/js/boot': 'resources/admin/boot.js',
                    'admin/js/fluent-mail-admin-app': 'resources/admin/start.js',
                    'admin/css/fluent-mail-admin': 'resources/scss/fluent-mail-admin.scss',
                },
                output: {
                    entryFileNames: '[name].js',
                    assetFileNames: '[name][extname]',
                    chunkFileNames: 'admin/js/chunks/[name].js',
                },
            },
        },
    });
  10. Directory Structure for Admin Resources

    master

    New shell components must be placed under resources/admin/. Do not move this directory to src/, as the build.sh script is configured to exclude resources/* from the final zip package.

    resources/admin/
      App.vue                     # Rewrite of Application.vue (app bar + nav + theme switch)
      Bits/ThemeSwitch.vue       # Copied from fluent-security
      Bits/icons.js               # Curated @element-plus/icons-vue re-exports
      styles/
        _theme.scss              # Light + dark token declarations
        _layout.scss             # App bar, settings shell, cards, rows, tags
        tokens/
          color.js
          spacing.js
          borderRadius.js
          fontSize.js
    resources/admin/
      App.vue                     ← rewrite of Application.vue: app bar + nav + theme switch
      Bits/ThemeSwitch.vue       ← copied from fluent-security
      Bits/icons.js               ← curated @element-plus/icons-vue re-exports
      styles/
        _theme.scss               ← light + dark token declarations
        _layout.scss              ← app bar, settings shell, cards, rows, tags
        tokens/{color,spacing,borderRadius,fontSize}.js
  11. Install and set up FluentSMTP for development

    master

    To set up the FluentSMTP repository for local development, follow these steps to install both PHP and frontend dependencies:

    1. Clone the repository.
    2. Install PHP dependencies: Run composer install.
    3. Install frontend dependencies: Run pnpm install.

    Note: Use pnpm instead of npm to ensure the pnpm-lock.yaml file is respected and versions are resolved correctly.

    Once installed, you can start the development environment by running pnpm run dev (or pnpm run start). This builds boot.js once and then watches the app bundle for changes.

    clone this repository
    composer install
    pnpm install
    pnpm run dev