public static function send(array $params): array { $to = $params['to'] ?? null; $template = $params['template'] ?? null; $lang = $params['lang'] ?? 'de'; $data = $params['data'] ?? []; if (!$to || !$template) { self::log("ERROR → Fehlende Parameter: to oder template"); return ['success' => false, 'error' => 'to und template sind Pflichtfelder']; } // Template suchen $possibleFiles = [ "/var/www/html/C/templates/email/{$template}.{$lang}.html", "/var/www/html/C/templates/email/{$template}.de.html", "/var/www/html/C/templates/email/{$template}.html" ]; $templateFile = null; foreach ($possibleFiles as $file) { if (file_exists($file)) { $templateFile = $file; break; } } if (!$templateFile) { $error = "Template nicht gefunden: {$template}"; self::log("ERROR → $to | $error"); return ['success' => false, 'error' => $error]; } $html = file_get_contents($templateFile); // Platzhalter sicher ersetzen (wichtig: immer als String behandeln) foreach ($data as $k => $v) { $search = '{{' . $k . '}}'; $replace = $v !== null ? htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8') : ''; $html = str_replace($search, $replace, $html); } // Subject extrahieren preg_match('/(.*?)<\/title>/is', $html, $matches); $subject = trim($matches[1] ?? 'Nachricht von AOE Services'); // Config laden $config = include '/var/www/html/C/config/communication.php'; $smtp = $config['providers']['smtp'] ?? []; $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = $smtp['host'] ?? 'smtp.office365.com'; $mail->SMTPAuth = true; $mail->Username = $smtp['username'] ?? ''; $mail->Password = $smtp['password'] ?? ''; $mail->SMTPSecure = $smtp['security'] ?? PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = $smtp['port'] ?? 587; $mail->CharSet = 'UTF-8'; $mail->setFrom($smtp['from_email'] ?? 'support@aoe.services', $smtp['from_name'] ?? 'AOE Services'); $mail->addAddress($to); $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $html; $mail->AltBody = strip_tags($html); $mail->send(); self::log("OK → $to | template=$template | lang=$lang"); return ['success' => true, 'message' => 'E-Mail erfolgreich gesendet']; } catch (PHPMailerException $e) { $errorMsg = $mail->ErrorInfo; self::log("ERROR → $to | $errorMsg"); return ['success' => false, 'error' => $errorMsg]; } } <!DOCTYPE html> <html lang="de"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="AOE Plattform - Ihre All-in-One Business Lösung"> <meta name="robots" content="index, follow"> <title>AOE Plattform

Ihr Warenkorb

🛒 Ihr Warenkorb ist leer

Fügen Sie Produkte aus den Angeboten hinzu
✨ Unterstütze regionale Anbieter in deiner Nähe!
🍃 Frische Produkte direkt aus deiner Region
💚 Qualität, die in der Region bleibt
🤝 Gemeinsam stark – lokal einkaufen
PLZ 📍
🦉 AOE Owl – KI-Assistent
Ich helfe dir, deine Website & Apps zu steuern
Hallo! Ich bin dein persönlicher Assistent.
Du kannst mich zum Beispiel bitten:
• 🌐 „Erstelle eine Website für eine Bäckerei“
• 🎨 „Ändere die Farbe auf Blau“
• 📱 „Baue eine Terminbuchungs-App“
• 🤖 „Erstelle einen KI-Agenten für Kundenservice“
Probiere es einfach aus – ich bin für dich da!