SMTPDebug = SMTP::DEBUG_SERVER; // Enable this for detailed debugging $mail->isSMTP(); // Use SMTP $mail->Host = 'ophelia.kreativmedia.ch'; // Set SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'support@verua.ch'; // SMTP username $mail->Password = 'zki@U/*{A]}3#kS/Lg|)l]t:,XHuV=8I_'; // SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // Enable encryption $mail->Port = 465; // TCP port for the connection // Recipients $mail->setFrom('support@verua.ch', 'VeruA Support'); // Sender address $mail->addAddress('support@verua.ch', 'VeruA Support'); // Add another recipient // $mail->addBCC('ah@mediendesign-hnida.de'); // Add bounce email address as BCC $mail->addBCC('rabe@verua.swiss'); // Add bounce email address as BCC // Content Mail to support $mail->isHTML(true); // Email in HTML format $mail->CharSet = 'UTF-8'; $encodedSubject = mb_encode_mimeheader($subject, "UTF-8", "Q"); $mail->Subject = $encodedSubject; $mail->Body = nl2br(htmlspecialchars($message)); $mail->AltBody = htmlspecialchars($message); // Send email if ($mail->send()) { // Success response echo json_encode(['success' => true, 'message' => 'Nachricht wurde gesendet.']); http_response_code(200); // Send a second email to the customer $customerEmail = $email; $customerSubject = ($lang == "DE" ? 'Danke für Ihre Bestellung bei der VeruA AG' : 'Merci pour votre commande chez VeruA AG' ); $encodedSubject = mb_encode_mimeheader($customerSubject, "UTF-8", "Q"); $customerMessage = constructCustomerMessage($message, $lang); $mail->clearAddresses(); $mail->addAddress($customerEmail); $mail->Subject = $encodedSubject; $mail->Body = nl2br(htmlspecialchars($customerMessage)); $mail->AltBody = htmlspecialchars($customerMessage); $mail->send(); } } catch (Exception $e) { // Error response if an exception occurs echo json_encode(['success' => false, 'message' => "Nachricht konnte nicht gesendet werden. Mailer Error: {$mail->ErrorInfo}"]); } ?>