ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(extensions): Phase 4 — extract Email into serverkit-email extension
Juan Denisb59a57430e65
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 678aff11..11247544 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,15 @@ awaiting a stable release:### Added+- **Extensions platform (Phase 4 — Email is now an extension)** — the mail-server+ stack (Postfix/Dovecot, domains, mailboxes, DKIM/SpamAssassin, Roundcube webmail,+ and the `/api/v1/email` API) has moved out of core into the bundled+ **`serverkit-email`** extension. Panels that never run mail no longer load any of+ it — a real "smaller core" win. Existing panels that actually used mail+ auto-install the extension once on upgrade (detected by existing mail domains/+ accounts); everyone else finds it in the Marketplace. Outbound notification SMTP+ is unaffected — it never depended on the mail server. (The Email "module toggle"+ is retired in favor of installing/disabling the extension.)- **Extensions platform (Phase 3 — platform primitives)** — the machinery thatmakes extensions first-class and safe. Extensions can now own **data models**(manifest `models` → `ext_<slug>_*` tables, created on install, dropped ondiff --git a/backend/app/__init__.py b/backend/app/__init__.pyindex b66f9170..dcae0977 100644--- a/backend/app/__init__.py+++ b/backend/app/__init__.py@@ -265,12 +265,11 @@ def create_app(config_name=None):from app.api.cron import cron_bpapp.register_blueprint(cron_bp, url_prefix='/api/v1/cron')- # Register blueprints - Email Server- from app.api.email import email_bp- # Email is a toggleable module (#14): 503 its API when disabled.- from app.services.module_service import attach_module_guard as _attach_module_guard_email- _attach_module_guard_email(email_bp, 'email')- app.register_blueprint(email_bp, url_prefix='/api/v1/email')+ # Email Server is now the serverkit-email builtin extension (Phase 4, #32):+ # its /api/v1/email blueprint + Postfix/Dovecot/DKIM/SpamAssassin/Roundcube+ # services live in builtin-extensions/serverkit-email/ and are registered by+ # the plugin loader when installed. The outbound relay (email_relay_service)+ # and all email models stay core (notifications SMTP + shared Postfix relay).# Register blueprints - Uptime Trackingfrom app.api.uptime import uptime_bpdiff --git a/backend/app/services/extension_migration.py b/backend/app/services/extension_migration.pyindex c21d2ef8..c79adb1b 100644--- a/backend/app/services/extension_migration.py+++ b/backend/app/services/extension_migration.py@@ -31,6 +31,27 @@ CONVERTED_BUILTIN_SLUGS = ['serverkit-workflows',]++def _email_was_configured():+ """True if this panel actually ran a mail server before the extraction — any+ email domain/account row exists. Used to gate serverkit-email auto-install so+ only mail users get it back automatically (#34); everyone else uses the+ Marketplace."""+ try:+ from app.models.email import EmailDomain, EmailAccount+ return (db.session.query(EmailDomain.id).first() is not None+ or db.session.query(EmailAccount.id).first() is not None)+ except Exception:+ return False+++# Builtins auto-installed on upgrade ONLY when a usage predicate says the panel+# actually used the feature (D3/#34). Fresh installs and panels that never used+# the feature just see it in the Marketplace.+GATED_BUILTIN_SLUGS = {+ 'serverkit-email': _email_was_configured,+}+_MARKER_KEY = 'extensions.auto_installed_slugs'@@ -78,8 +99,13 @@ def run_auto_install():logger.warning(f'Extension auto-install skipped (builtins unavailable): {e}')return+ # Ungated converted builtins auto-install on any upgrade; gated ones only when+ # their usage predicate is true.+ candidates = [(s, None) for s in CONVERTED_BUILTIN_SLUGS]+ candidates += [(s, gate) for s, gate in GATED_BUILTIN_SLUGS.items()]+changed = False- for slug in CONVERTED_BUILTIN_SLUGS:+ for slug, gate in candidates:if slug in processed:continue@@ -88,8 +114,15 @@ def run_auto_install():continueif existing:- # Upgrade path: keep the feature alive unless it's already present.- if not InstalledPlugin.query.filter_by(slug=slug).first():+ # Upgrade path: keep the feature alive unless it's already present or+ # (for gated builtins) the panel never used it.+ wants_it = True+ if gate is not None:+ try:+ wants_it = bool(gate())+ except Exception:+ wants_it = False+ if wants_it and not InstalledPlugin.query.filter_by(slug=slug).first():try:install_builtin_extension(slug)logger.info(f'Auto-installed converted builtin extension: {slug}')@@ -98,7 +131,8 @@ def run_auto_install():f'Auto-install of {slug} failed (retry next boot): {e}')continue # leave unmarked so we retry- # Fresh install (marketplace-only) OR successfully installed: record it.+ # Fresh install (marketplace-only), gate-false (marketplace-only), OR+ # successfully installed: record it so the one-shot never repeats.processed.add(slug)changed = Truediff --git a/backend/app/services/module_service.py b/backend/app/services/module_service.pyindex e8f8d695..fc448d41 100644--- a/backend/app/services/module_service.py+++ b/backend/app/services/module_service.py@@ -15,11 +15,11 @@ import logginglogger = logging.getLogger(__name__)# name -> presentation metadata. The settings key is module_<name>_enabled.+#+# Email used to be a module toggle here; it's now the serverkit-email extension+# (Phase 4, #32) — install/disable it from the Marketplace instead. WordPress+# remains a core module toggle until its own extraction (Phase 5, #38).MODULES = {- 'email': {- 'label': 'Email Server',- 'description': 'Postfix/Dovecot mail stack, delivery logs, and the /api/v1/email API.',- },'wordpress': {'label': 'WordPress','description': 'WordPress site management, plugin library, and the /api/v1/wordpress API.',diff --git a/backend/app/services/settings_service.py b/backend/app/services/settings_service.pyindex e4bd6b2a..d5a7f2e1 100644--- a/backend/app/services/settings_service.py+++ b/backend/app/services/settings_service.py@@ -127,7 +127,6 @@ class SettingsService:# extensions yet (Email, WordPress). Disabling hides the nav + routes and# 503s the module's API (same mechanism as the plugin status guard). The# toggle state later becomes the extraction auto-install signal (#34).- 'module_email_enabled': {'value': True, 'type': 'boolean', 'description': 'Show the Email server module (nav, routes, and /api/v1/email).'},'module_wordpress_enabled': {'value': True, 'type': 'boolean', 'description': 'Show the WordPress module (nav, routes, and /api/v1/wordpress).'},}diff --git a/backend/tests/test_email_extraction.py b/backend/tests/test_email_extraction.pynew file mode 100644index 00000000..2d4a3075--- /dev/null+++ b/backend/tests/test_email_extraction.py@@ -0,0 +1,73 @@+"""Prove the Email extraction (Phase 4, #35).++A core panel no longer carries the mail-server API; installing the serverkit-email+builtin registers `/api/v1/email` and its routes respond (which also exercises the+extension's relative-import rewiring). Uninstall removes it again.+"""+import sys++import pytest++import app as app_pkg+from app.models.plugin import InstalledPlugin+from app.services import plugin_service++SLUG = 'serverkit-email'+_PKG = f'app.plugins.{SLUG}'+++def test_core_has_no_email_routes(app):+ """The mail-server API is gone from core after extraction."""+ rules = [r.rule for r in app.url_map.iter_rules()]+ assert not any(r.startswith('/api/v1/email') for r in rules)+++def install_dirs(tmp_path, monkeypatch):+ """Point the install targets at temp dirs AND make app.plugins resolve the+ temp backend dir so the hot-loaded blueprint imports from there (not the repo).+ """+ backend = tmp_path / 'plugins_backend'+ frontend = tmp_path / 'plugins_frontend'+ backend.mkdir()+ frontend.mkdir()+ monkeypatch.setattr(plugin_service, 'BACKEND_PLUGINS_DIR', str(backend))+ monkeypatch.setattr(plugin_service, 'FRONTEND_PLUGINS_DIR', str(frontend))++ added = str(backend)+ import importlib+ app_pkg_plugins = importlib.import_module('app.plugins')+ if added not in app_pkg_plugins.__path__:+ app_pkg_plugins.__path__.append(added)++ yield {'backend': backend, 'frontend': frontend}++ # Clean the import side effects so other tests see a pristine module graph.+ if added in app_pkg_plugins.__path__:+ app_pkg_plugins.__path__.remove(added)+ for name in list(sys.modules):+ if name == _PKG or name.startswith(_PKG + '.'):+ del sys.modules[name]+++def test_install_email_extension_registers_routes(app, client, auth_headers, install_dirs):+ # The real builtin folder is discovered from the repo's builtin-extensions/.+ available = {e['slug'] for e in plugin_service.list_builtin_extensions()}+ assert SLUG in available, 'serverkit-email builtin folder should exist'++ plugin = plugin_service.install_builtin_extension('serverkit-email')+ assert plugin.status == InstalledPlugin.STATUS_ACTIVE+ assert plugin.has_backend is True+ assert plugin.url_prefix == '/api/v1/email'++ # The blueprint hot-loaded: /api/v1/email/status now exists (not 404) and the+ # status guard passes for an active plugin (not 503). Its handler may 200 or+ # 500 depending on host mail state — we only assert the route is wired.+ resp = client.get('/api/v1/email/status', headers=auth_headers)+ assert resp.status_code not in (404, 503), resp.status_code+++def test_uninstall_removes_email_plugin(app, install_dirs):+ plugin = plugin_service.install_builtin_extension('serverkit-email')+ assert plugin_service.uninstall_plugin(plugin.id) is True+ assert InstalledPlugin.query.filter_by(slug=SLUG).first() is Nonediff --git a/backend/tests/test_module_toggles.py b/backend/tests/test_module_toggles.pyindex 10988d60..77053ade 100644--- a/backend/tests/test_module_toggles.py+++ b/backend/tests/test_module_toggles.py@@ -1,4 +1,8 @@-"""Module toggles (#14): hide/503 heavy verticals (Email, WordPress) on demand."""+"""Module toggles (#14): hide/503 a core vertical on demand.++Email used to be a module toggle; it's now the serverkit-email extension (#32),+so WordPress is the remaining core module and drives these tests.+"""from app.services import module_service@@ -6,12 +10,13 @@ def test_modules_default_enabled(app, client, auth_headers):resp = client.get('/api/v1/modules', headers=auth_headers)assert resp.status_code == 200mods = {m['name']: m for m in resp.get_json()['modules']}- assert mods['email']['enabled'] is Trueassert mods['wordpress']['enabled'] is True+ # Email is no longer a module toggle (it's an extension now).+ assert 'email' not in modsdef test_toggle_requires_admin_body(app, client, auth_headers):- resp = client.put('/api/v1/modules/email', headers=auth_headers, json={})+ resp = client.put('/api/v1/modules/wordpress', headers=auth_headers, json={})assert resp.status_code == 400@@ -20,23 +25,23 @@ def test_unknown_module_404(app, client, auth_headers):assert resp.status_code == 404-def test_email_api_503s_when_module_disabled(app, client, auth_headers):- # Enabled → the email status route is reachable (any 2xx/4xx that isn't 503).- resp = client.get('/api/v1/email/status', headers=auth_headers)+def test_wordpress_api_503s_when_module_disabled(app, client, auth_headers):+ # Enabled → the wordpress route is reachable (any status that isn't 503).+ resp = client.get('/api/v1/wordpress/sites', headers=auth_headers)assert resp.status_code != 503# Disable via the API, then the same route is guarded with 503.- toggle = client.put('/api/v1/modules/email', headers=auth_headers, json={'enabled': False})+ toggle = client.put('/api/v1/modules/wordpress', headers=auth_headers, json={'enabled': False})assert toggle.status_code == 200assert toggle.get_json()['enabled'] is False- resp = client.get('/api/v1/email/status', headers=auth_headers)+ resp = client.get('/api/v1/wordpress/sites', headers=auth_headers)assert resp.status_code == 503- assert resp.get_json()['module'] == 'email'+ assert resp.get_json()['module'] == 'wordpress'# Re-enable restores it.- client.put('/api/v1/modules/email', headers=auth_headers, json={'enabled': True})- resp = client.get('/api/v1/email/status', headers=auth_headers)+ client.put('/api/v1/modules/wordpress', headers=auth_headers, json={'enabled': True})+ resp = client.get('/api/v1/wordpress/sites', headers=auth_headers)assert resp.status_code != 503diff --git a/builtin-extensions/serverkit-email/backend/__init__.py b/builtin-extensions/serverkit-email/backend/__init__.pynew file mode 100644index 00000000..51e67b6d--- /dev/null+++ b/builtin-extensions/serverkit-email/backend/__init__.py@@ -0,0 +1 @@+"""ServerKit Email extension backend package."""diff --git a/backend/app/services/dkim_service.py b/builtin-extensions/serverkit-email/backend/dkim_service.pysimilarity index 100%rename from backend/app/services/dkim_service.pyrename to builtin-extensions/serverkit-email/backend/dkim_service.pydiff --git a/backend/app/services/dovecot_service.py b/builtin-extensions/serverkit-email/backend/dovecot_service.pysimilarity index 100%rename from backend/app/services/dovecot_service.pyrename to builtin-extensions/serverkit-email/backend/dovecot_service.pydiff --git a/backend/app/api/email.py b/builtin-extensions/serverkit-email/backend/email.pysimilarity index 95%rename from backend/app/api/email.pyrename to builtin-extensions/serverkit-email/backend/email.pyindex 5a49853c..fb090e33 100644--- a/backend/app/api/email.py+++ b/builtin-extensions/serverkit-email/backend/email.py@@ -1,13 +1,19 @@-"""Email Server API endpoints for managing mail services, domains, accounts, and DNS."""+"""Email Server API endpoints for managing mail services, domains, accounts, and DNS.++Lives in the serverkit-email extension (app.plugins.serverkit-email.email after+install). Intra-extension modules are imported relatively; core services+(postfix relay, DNS, relay-config, RBAC) are imported absolutely — the mail+server extends the core, never the other way around.+"""from flask import Blueprint, request, jsonify-from ..middleware.rbac import admin_required, viewer_required-from ..services.email_service import EmailService-from ..services.dns_provider_service import DNSProviderService-from ..services.spamassassin_service import SpamAssassinService-from ..services.roundcube_service import RoundcubeService-from ..services.postfix_service import PostfixService-from ..services.email_relay_service import EmailRelayService+from app.middleware.rbac import admin_required, viewer_required+from app.services.dns_provider_service import DNSProviderService+from app.services.postfix_service import PostfixService+from app.services.email_relay_service import EmailRelayService+from .email_service import EmailService+from .spamassassin_service import SpamAssassinService+from .roundcube_service import RoundcubeServiceemail_bp = Blueprint('email', __name__)diff --git a/backend/app/services/email_service.py b/builtin-extensions/serverkit-email/backend/email_service.pysimilarity index 98%rename from backend/app/services/email_service.pyrename to builtin-extensions/serverkit-email/backend/email_service.pyindex f31f93b4..de2333c1 100644--- a/backend/app/services/email_service.py+++ b/builtin-extensions/serverkit-email/backend/email_service.py@@ -6,11 +6,11 @@ from typing import Dict, List, Optionalfrom app import dbfrom app.models.email import EmailDomain, EmailAccount, EmailAlias, EmailForwardingRulefrom app.services.postfix_service import PostfixService-from app.services.dovecot_service import DovecotService-from app.services.dkim_service import DKIMService-from app.services.spamassassin_service import SpamAssassinService-from app.services.roundcube_service import RoundcubeServicefrom app.utils.system import PackageManager, ServiceControl+from .dovecot_service import DovecotService+from .dkim_service import DKIMService+from .spamassassin_service import SpamAssassinService+from .roundcube_service import RoundcubeServicelogger = logging.getLogger(__name__)diff --git a/backend/app/services/roundcube_service.py b/builtin-extensions/serverkit-email/backend/roundcube_service.pysimilarity index 100%rename from backend/app/services/roundcube_service.pyrename to builtin-extensions/serverkit-email/backend/roundcube_service.pydiff --git a/backend/app/services/spamassassin_service.py b/builtin-extensions/serverkit-email/backend/spamassassin_service.pysimilarity index 100%rename from backend/app/services/spamassassin_service.pyrename to builtin-extensions/serverkit-email/backend/spamassassin_service.pydiff --git a/builtin-extensions/serverkit-email/frontend/index.jsx b/builtin-extensions/serverkit-email/frontend/index.jsxnew file mode 100644index 00000000..2d8284d5--- /dev/null+++ b/builtin-extensions/serverkit-email/frontend/index.jsx@@ -0,0 +1,13 @@+// Email Server, contributed through the extension system. The full mail-server+// backend (Postfix/Dovecot/DKIM/SpamAssassin/Roundcube orchestration + the+// /api/v1/email blueprint) lives in this extension's backend/; the page+// component stays in the host pages/ dir and is re-exported here (same pattern+// as serverkit-git/gpu/workflows) so its many relative imports keep resolving.+//+// After sync this file lives at frontend/src/plugins/serverkit-email/ so the+// relative import resolves against the host's pages directory.+import Email from '../../pages/Email';++export function EmailPage() {+ return <Email />;+}diff --git a/builtin-extensions/serverkit-email/plugin.json b/builtin-extensions/serverkit-email/plugin.jsonnew file mode 100644index 00000000..5311b112--- /dev/null+++ b/builtin-extensions/serverkit-email/plugin.json@@ -0,0 +1,41 @@+{+ "name": "serverkit-email",+ "display_name": "Email Server",+ "version": "1.0.0",+ "description": "Full mail-server stack — Postfix/Dovecot, domains, mailboxes, aliases, DKIM/SPF/DMARC, SpamAssassin filtering, and Roundcube webmail. Most panels never run a mail server, so it ships as an opt-in extension.",+ "author": "ServerKit",+ "license": "MIT",+ "category": "integration",+ "homepage": "https://github.com/jhd3197/ServerKit",+ "permissions": ["shell", "filesystem", "network"],+ "min_panel_version": "1.7.0",+ "entry_point": "email:email_bp",+ "url_prefix": "/api/v1/email",+ "icon": "<path d=\"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z\"/><polyline points=\"22,6 12,13 2,6\"/>",+ "contributions": {+ "nav": [+ {+ "id": "email",+ "label": "Email Server",+ "route": "/email",+ "category": "operations",+ "icon": "<path d=\"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z\"/><polyline points=\"22,6 12,13 2,6\"/>"+ }+ ],+ "routes": [+ { "path": "email", "component": "EmailPage" },+ { "path": "email/:tab", "component": "EmailPage" }+ ],+ "page_titles": {+ "/email": "Email Server"+ },+ "command_palette": [+ {+ "label": "Email",+ "path": "/email",+ "category": "Pages",+ "keywords": "smtp postfix dovecot mail imap dkim webmail"+ }+ ]+ }+}diff --git a/docs/EXTRACTION_EMAIL_AUDIT.md b/docs/EXTRACTION_EMAIL_AUDIT.mdindex 1fb72fc2..7dfc36c4 100644--- a/docs/EXTRACTION_EMAIL_AUDIT.md+++ b/docs/EXTRACTION_EMAIL_AUDIT.md@@ -1,11 +1,27 @@# Email extraction — boundary audit (Phase 4, #31)-**Status:** Audit complete — extraction (#32–#35) is the follow-up.-**Verdict:** the mail-**server** stack is cleanly extractable. Two shared assets-must stay core; one core→email boot hook must be guarded. Notifications SMTP is-already independent and keeps working without the extension.--This is the hard gate the plan requires before moving any code (#32). It maps+**Status:** ✅ Audit complete AND extraction shipped (#32–#35, `serverkit-email`).+**Verdict:** the mail-**server** stack is cleanly extractable. Notifications SMTP is+independent and keeps working without the extension.++> **Deviations discovered during execution (vs. this audit's first draft):**+> 1. **`postfix_service` stays core.** The audit listed it as "moves (import only)",+> but `email_relay_service` (core, notifications-side) *actively uses*+> `PostfixService.configure_relay/disable_relay/get_status`. Postfix is shared+> outbound-relay infra, so it stays core; the extension imports it (extension→core).+> 2. **Email models stay core.** Kept in `app/models/email.py` (the audit's sanctioned+> two-speed option). This makes the `DNSProviderConfig` relocation a non-issue+> (it stays core with the other email models) and avoids a risky data migration —+> the server stack has no external model importers.+> 3. **Frontend uses the re-export pattern** (page stays in `pages/Email.jsx`, the+> extension owns the route) — same as serverkit-git/gpu/workflows — rather than+> physically relocating a 1000-line component and rewriting its imports.+>+> Net moved: `api/email.py` + `email_service`/`dovecot`/`dkim`/`spamassassin`/`roundcube`+> (6 files, intra-extension relative imports; core imports absolute). Core lost the+> mail-server API and 5 services; the "Email" module toggle became the extension itself.++This is the hard gate the plan required before moving any code (#32). It mapsevery touchpoint so the move is mechanical.---diff --git a/frontend/src/App.jsx b/frontend/src/App.jsxindex f41569f2..3fb05122 100644--- a/frontend/src/App.jsx+++ b/frontend/src/App.jsx@@ -51,7 +51,6 @@ import WordPressProjects from './pages/WordPressProjects';import WordPressPluginLibrary from './pages/WordPressPluginLibrary';import WordPressProject from './pages/WordPressProject';import SSLCertificates from './pages/SSLCertificates';-import Email from './pages/Email';import SSOCallback from './pages/SSOCallback';import SourceConnectionCallback from './pages/SourceConnectionCallback';import DatabaseMigration from './pages/DatabaseMigration';@@ -113,7 +112,6 @@ const PAGE_TITLES = {'/backups': 'Backups','/cron': 'Cron Jobs','/security': 'Security',- '/email': 'Email Server','/terminal': 'Terminal','/settings': 'Settings','/connections/callback/github': 'GitHub Connection',@@ -438,8 +436,8 @@ function AppRoutes() {</Route>{/* Email routes are gated by the Email module toggle(Settings → Modules); disabled ⇒ redirect to the dashboard. */}- <Route path="email" element={<ModuleRoute name="email"><Email /></ModuleRoute>} />- <Route path="email/:tab" element={<ModuleRoute name="email"><Email /></ModuleRoute>} />+ {/* /email is now the serverkit-email builtin extension (contributes+ the route via its manifest). */}<Route path="terminal" element={<Terminal />} /><Route path="terminal/terminal" element={<Navigate to="/terminal/shell" replace />} /><Route path="terminal/:tab" element={<Terminal />} />diff --git a/frontend/src/components/CommandPalette.jsx b/frontend/src/components/CommandPalette.jsxindex 2a27c1cb..96b2aeb2 100644--- a/frontend/src/components/CommandPalette.jsx+++ b/frontend/src/components/CommandPalette.jsx@@ -27,7 +27,6 @@ const STATIC_PAGES = [{ label: 'Backups', path: '/backups', category: 'Pages', keywords: 'snapshots restore' },{ label: 'Cron Jobs', path: '/cron', category: 'Pages', keywords: 'schedule tasks' },{ label: 'Security', path: '/security', category: 'Pages', keywords: 'firewall fail2ban' },- { label: 'Email', path: '/email', category: 'Pages', keywords: 'smtp postfix' },{ label: 'Terminal', path: '/terminal', category: 'Pages', keywords: 'shell ssh console' },{ label: 'Servers', path: '/servers', category: 'Pages', keywords: 'fleet agents' },{ label: 'Fleet Monitor', path: '/fleet-monitor', category: 'Pages', keywords: 'agents status' },diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsxindex 1d30970a..6633da80 100644--- a/frontend/src/components/Sidebar.jsx+++ b/frontend/src/components/Sidebar.jsx@@ -112,13 +112,12 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {.catch(() => setGpuAvailable(false));}, []);- // Feature-module toggles (Email + WordPress). Default to enabled until the- // shared module state loads so items never flicker/hide prematurely.+ // Feature-module toggles (WordPress; Email is now an extension). Default to+ // enabled until the shared module state loads so items never flicker/hide.const { isEnabled: isModuleEnabled } = useModules();- const emailEnabled = isModuleEnabled('email');const wordpressEnabled = isModuleEnabled('wordpress');- const conditions = { wpInstalled, gpuAvailable, emailEnabled, wordpressEnabled };+ const conditions = { wpInstalled, gpuAvailable, wordpressEnabled };const currentPreset = user?.sidebar_config?.preset || 'recommended';const [manualExpanded, setManualExpanded] = useState({});const [autoExpanded, setAutoExpanded] = useState(null);@@ -159,7 +158,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {// Top-level items can gate on a runtime condition (e.g. GPU Monitor// only when a GPU is present, or the Email/WordPress modules being// enabled), mirroring sub-item requiresCondition.- const conds = { wpInstalled, gpuAvailable, emailEnabled, wordpressEnabled };+ const conds = { wpInstalled, gpuAvailable, wordpressEnabled };const items = [...core, ...fromPlugins].filter((item) => !item.requiresCondition || conds[item.requiresCondition]);@@ -176,7 +175,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {}}return applyWorkspaceNavPermissions(items, activeWorkspace, user);- }, [user?.sidebar_config, pluginNav, wpInstalled, gpuAvailable, emailEnabled, wordpressEnabled, user]);+ }, [user?.sidebar_config, pluginNav, wpInstalled, gpuAvailable, wordpressEnabled, user]);// Group visible items by categoryconst groupedItems = useMemo(() => {diff --git a/frontend/src/components/sidebarItems.js b/frontend/src/components/sidebarItems.jsindex f5582b28..69260a96 100644--- a/frontend/src/components/sidebarItems.js+++ b/frontend/src/components/sidebarItems.js@@ -165,15 +165,8 @@ export const SIDEBAR_ITEMS = [category: 'operations',icon: '<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><path d="M12 8v4m0 4h.01"/>'},- {- id: 'email',- label: 'Email Server',- route: '/email',- category: 'operations',- // Hidden when an admin disables the Email module (Settings → Modules).- requiresCondition: 'emailEnabled',- icon: '<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/>'- },+ // Email Server is now the serverkit-email builtin extension; its sidebar item+ // is contributed by the extension manifest.{id: 'queue',label: 'Queue Bus',diff --git a/frontend/src/plugins/serverkit-email/index.jsx b/frontend/src/plugins/serverkit-email/index.jsxnew file mode 100644index 00000000..2d8284d5--- /dev/null+++ b/frontend/src/plugins/serverkit-email/index.jsx@@ -0,0 +1,13 @@+// Email Server, contributed through the extension system. The full mail-server+// backend (Postfix/Dovecot/DKIM/SpamAssassin/Roundcube orchestration + the+// /api/v1/email blueprint) lives in this extension's backend/; the page+// component stays in the host pages/ dir and is re-exported here (same pattern+// as serverkit-git/gpu/workflows) so its many relative imports keep resolving.+//+// After sync this file lives at frontend/src/plugins/serverkit-email/ so the+// relative import resolves against the host's pages directory.+import Email from '../../pages/Email';++export function EmailPage() {+ return <Email />;+}diff --git a/frontend/src/plugins/serverkit-email/plugin.json b/frontend/src/plugins/serverkit-email/plugin.jsonnew file mode 100644index 00000000..5d38180a--- /dev/null+++ b/frontend/src/plugins/serverkit-email/plugin.json@@ -0,0 +1,51 @@+{+ "name": "serverkit-email",+ "display_name": "Email Server",+ "version": "1.0.0",+ "description": "Full mail-server stack — Postfix/Dovecot, domains, mailboxes, aliases, DKIM/SPF/DMARC, SpamAssassin filtering, and Roundcube webmail. Most panels never run a mail server, so it ships as an opt-in extension.",+ "author": "ServerKit",+ "license": "MIT",+ "category": "integration",+ "homepage": "https://github.com/jhd3197/ServerKit",+ "permissions": [+ "shell",+ "filesystem",+ "network"+ ],+ "min_panel_version": "1.7.0",+ "entry_point": "email:email_bp",+ "url_prefix": "/api/v1/email",+ "icon": "<path d=\"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z\"/><polyline points=\"22,6 12,13 2,6\"/>",+ "contributions": {+ "nav": [+ {+ "id": "email",+ "label": "Email Server",+ "route": "/email",+ "category": "operations",+ "icon": "<path d=\"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z\"/><polyline points=\"22,6 12,13 2,6\"/>"+ }+ ],+ "routes": [+ {+ "path": "email",+ "component": "EmailPage"+ },+ {+ "path": "email/:tab",+ "component": "EmailPage"+ }+ ],+ "page_titles": {+ "/email": "Email Server"+ },+ "command_palette": [+ {+ "label": "Email",+ "path": "/email",+ "category": "Pages",+ "keywords": "smtp postfix dovecot mail imap dkim webmail"+ }+ ]+ }+}