'use client'; import { useState } from 'react'; import { Mail, ArrowLeft } from 'lucide-react'; interface ProviderPreset { id: string; name: string; logo: string; domains: string[]; imap_ssl?: { host: string; port: number } | null; pop3_ssl?: { host: string; port: number } | null; notes?: string; } interface ProviderConfig { name: string; provider_name: string; protocol: string; host: string; port: number; use_ssl: boolean; } interface ProviderWizardProps { onSelect: (config: ProviderConfig) => void; onManual: () => void; } const PROVIDERS: ProviderPreset[] = [ { id: 'gmail', name: 'Gmail', logo: '/providers/gmail.svg', domains: ['gmail.com', 'googlemail.com'], imap_ssl: { host: 'imap.gmail.com', port: 993 }, pop3_ssl: { host: 'pop.gmail.com', port: 995 }, notes: 'Enable IMAP/POP3 in Gmail settings. Use an App Password if 2FA is enabled.', }, { id: 'gmx', name: 'GMX', logo: '/providers/gmx.svg', domains: ['gmx.de', 'gmx.net', 'gmx.at', 'gmx.ch', 'gmx.com'], imap_ssl: { host: 'imap.gmx.net', port: 993 }, pop3_ssl: { host: 'pop.gmx.net', port: 995 }, notes: 'Enable POP3/IMAP in GMX settings under E-Mail > POP3/IMAP Abruf.', }, { id: 'webde', name: 'WEB.DE', logo: '/providers/webde.svg', domains: ['web.de'], imap_ssl: { host: 'imap.web.de', port: 993 }, pop3_ssl: { host: 'pop3.web.de', port: 995 }, notes: 'Enable POP3/IMAP in WEB.DE settings under E-Mail > POP3/IMAP Abruf.', }, { id: 'outlook', name: 'Outlook / Hotmail', logo: '/providers/outlook.svg', domains: ['outlook.com', 'hotmail.com', 'live.com', 'msn.com', 'outlook.de'], imap_ssl: { host: 'outlook.office365.com', port: 993 }, pop3_ssl: { host: 'outlook.office365.com', port: 995 }, notes: 'Use your Microsoft account credentials.', }, { id: 'yahoo', name: 'Yahoo Mail', logo: '/providers/yahoo.svg', domains: ['yahoo.com', 'yahoo.de', 'yahoo.co.uk', 'ymail.com'], imap_ssl: { host: 'imap.mail.yahoo.com', port: 993 }, pop3_ssl: { host: 'pop.mail.yahoo.com', port: 995 }, notes: 'Generate an App Password in Yahoo account security settings.', }, { id: 'aol', name: 'AOL Mail', logo: '/providers/aol.svg', domains: ['aol.com', 'aim.com'], imap_ssl: { host: 'imap.aol.com', port: 993 }, pop3_ssl: { host: 'pop.aol.com', port: 995 }, notes: 'Generate an App Password in AOL account security settings.', }, { id: 'tonline', name: 'T-Online', logo: '/providers/tonline.svg', domains: ['t-online.de'], imap_ssl: { host: 'secureimap.t-online.de', port: 993 }, pop3_ssl: { host: 'securepop.t-online.de', port: 995 }, notes: 'Use your T-Online E-Mail-Passwort (not your Telekom login password).', }, { id: 'ionos', name: '1&1 / IONOS', logo: '/providers/ionos.svg', domains: ['online.de', 'onlinehome.de', '1und1.de'], imap_ssl: { host: 'imap.ionos.de', port: 993 }, pop3_ssl: { host: 'pop.ionos.de', port: 995 }, notes: 'Use your IONOS email credentials.', }, { id: 'freenet', name: 'Freenet', logo: '/providers/freenet.svg', domains: ['freenet.de'], imap_ssl: { host: 'mx.freenet.de', port: 993 }, pop3_ssl: { host: 'mx.freenet.de', port: 995 }, notes: 'Use your Freenet email credentials.', }, { id: 'icloud', name: 'iCloud Mail', logo: '/providers/icloud.svg', domains: ['icloud.com', 'me.com', 'mac.com'], imap_ssl: { host: 'imap.mail.me.com', port: 993 }, pop3_ssl: null, notes: 'Generate an app-specific password at appleid.apple.com. IMAP only.', }, { id: 'posteo', name: 'Posteo', logo: '/providers/posteo.svg', domains: ['posteo.de', 'posteo.net'], imap_ssl: { host: 'posteo.de', port: 993 }, pop3_ssl: null, notes: 'Posteo supports IMAP only.', }, { id: 'protonmail', name: 'Proton Mail', logo: '/providers/protonmail.svg', domains: ['proton.me', 'protonmail.com', 'protonmail.ch', 'pm.me'], imap_ssl: { host: '127.0.0.1', port: 1143 }, pop3_ssl: { host: '127.0.0.1', port: 1144 }, notes: 'Requires Proton Mail Bridge running locally. Use your Bridge password (not your Proton account password). Default Bridge ports: IMAP 127.0.0.1:1143, POP3 127.0.0.1:1144.', }, ]; export function ProviderWizard({ onSelect, onManual }: ProviderWizardProps) { const [selectedProvider, setSelectedProvider] = useState(null); const [selectedProtocol, setSelectedProtocol] = useState<'imap_ssl' | 'pop3_ssl'>('imap_ssl'); const handleProviderClick = (provider: ProviderPreset) => { setSelectedProvider(provider); // If only one protocol, auto-select it if (!provider.pop3_ssl && provider.imap_ssl) { setSelectedProtocol('imap_ssl'); } else if (provider.pop3_ssl && !provider.imap_ssl) { setSelectedProtocol('pop3_ssl'); } }; const handleConfirm = () => { if (!selectedProvider) return; const config = selectedProvider[selectedProtocol]; if (!config) return; onSelect({ name: selectedProvider.name, provider_name: selectedProvider.name, protocol: selectedProtocol === 'imap_ssl' ? 'imap_ssl' : 'pop3_ssl', host: config.host, port: config.port, use_ssl: true, }); }; if (selectedProvider) { return (

{selectedProvider.name}
{selectedProvider.name}

Domains: {selectedProvider.domains.join(', ')}

{selectedProvider.notes && (

{selectedProvider.notes}

)}
{selectedProvider.imap_ssl && ( )} {selectedProvider.pop3_ssl && ( )}
); } return (

Quick Setup — Select Your Email Provider

{PROVIDERS.map((provider) => ( ))}
or
); }