prepare('SELECT id FROM accounts WHERE username = ? OR email = ?'); $st->execute([$username, $email]); if ($st->fetch()) { $error = "Le compte « {$username} » existe déjà."; } else { db()->prepare( 'INSERT INTO accounts (username, email, display_name, smb_path) VALUES (?, ?, ?, ?)' )->execute([$username, $email, $display, $smbPath]); // Crée le dossier, l'utilisateur Dovecot et le share Samba $cmd = sprintf( '/opt/copymail/scripts/create_account.sh %s %s %s 2>&1', escapeshellarg($username), escapeshellarg($password), escapeshellarg($domain) ); shell_exec($cmd); flash('success', "Compte {$email} créé. Share SMB : \\\\serveur\\{$username}"); header('Location: /admin/accounts.php'); exit; } } } if ($_POST['action'] === 'delete') { $id = (int)$_POST['account_id']; $st = db()->prepare('SELECT username FROM accounts WHERE id = ?'); $st->execute([$id]); $row = $st->fetch(); if ($row) { $cmd = sprintf('/opt/copymail/scripts/delete_account.sh %s 2>&1', escapeshellarg($row['username'])); shell_exec($cmd); db()->prepare('DELETE FROM accounts WHERE id = ?')->execute([$id]); flash('success', "Compte « {$row['username']} » supprimé."); } header('Location: /admin/accounts.php'); exit; } if ($_POST['action'] === 'toggle') { $id = (int)$_POST['account_id']; db()->prepare('UPDATE accounts SET active = 1 - active WHERE id = ?')->execute([$id]); header('Location: /admin/accounts.php'); exit; } } $accounts = db()->query( 'SELECT a.*, COUNT(sf.id) as mail_count FROM accounts a LEFT JOIN source_file sf ON sf.account_id = a.id GROUP BY a.id ORDER BY a.created_at DESC' )->fetchAll(); $domain = cfg('domain'); html_head('Comptes'); html_navbar('accounts'); ?>
Nouveau compte
@
Lettres, chiffres, . _ -

La création génère automatiquement :
  • Boîte mail username@
  • Dossier /srv/copymail/username/
  • Share SMB \\serveur\username
Comptes existants
Aucun compte créé.
Compte Email Share SMB Mails Statut Actions

\\serveur\