From 022802a9a57b45cfdc9ddb77926383ecf48313e3 Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Fri, 23 Feb 2024 09:15:28 +0000 Subject: [PATCH] fixed Boterkennung durch Zeit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Formular Zusatzmodule Freiberufler hinzugefügt. message.php constructMessage() erweitert, so dass für alle Formulare nur diese eine Methode benötigt wird. --- public/php/ajaxmail.php | 109 ++++++++++++++++++++++++++++++++++++++++ public/php/mail.php | 47 +++++++++++++++++ public/php/message.php | 95 ++++++++++++++++++++++++++++++++++ 3 files changed, 251 insertions(+) create mode 100644 public/php/ajaxmail.php create mode 100644 public/php/mail.php create mode 100644 public/php/message.php diff --git a/public/php/ajaxmail.php b/public/php/ajaxmail.php new file mode 100644 index 0000000..00d7ef9 --- /dev/null +++ b/public/php/ajaxmail.php @@ -0,0 +1,109 @@ +SMTPDebug = SMTP::DEBUG_SERVER; // Enable this for detailed debugging + $mail->isSMTP(); // Use SMTP + $mail->Host = 'sslout.de'; // Set SMTP server + $mail->SMTPAuth = true; // Enable SMTP authentication + $mail->Username = 'ah@mediendesign-hnida.de'; // SMTP username + $mail->Password = 'jrd9h7RnVjf/'; // SMTP password + $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // Enable encryption + $mail->Port = 465; // TCP port for the connection + + // Recipients + $mail->setFrom($email, $name); // Sender address + $mail->addAddress('ah@mediendesign-hnida.de', 'Andreas Hnida'); // Add recipient + $mail->addReplyTo($email, $name); // Set reply address + $mail->addBCC('ah@mediendesign-hnida.de'); // Add bounce email address as BCC + + // Content + $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 = 'Danke für Ihre Bestellung - Verua RaBe Websolutions'; + $encodedSubject = mb_encode_mimeheader($customerSubject, "UTF-8", "Q"); + + $customerMessage = constructCustomerMessageDE($message); + + $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}"]); +} +?> diff --git a/public/php/mail.php b/public/php/mail.php new file mode 100644 index 0000000..b063078 --- /dev/null +++ b/public/php/mail.php @@ -0,0 +1,47 @@ +SMTPDebug = SMTP::DEBUG_SERVER; // Aktivieren Sie dies für detailliertes Debugging + $mail->isSMTP(); // SMTP verwenden + $mail->Host = 'sslout.de'; // SMTP-Server setzen + $mail->SMTPAuth = true; // SMTP-Authentifizierung aktivieren + $mail->Username = 'ah@mediendesign-hnida.de'; // SMTP-Benutzernamen angeben + $mail->Password = 'jrd9h7RnVjf/'; // SMTP-Passwort angeben + $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // Verschlüsselung aktivieren + $mail->Port = 465; // TCP-Port für die Verbindung + + // Empfänger + $mail->setFrom($email, $name); // Absenderadresse + $mail->addAddress('ah@mediendesign-hnida.de', 'Andreas Hnida'); // Empfänger hinzufügen + $mail->addReplyTo($email, $name); // Antwortadresse setzen + $mail->addBCC('ah@mediendesign-hnida.de'); // Bounce-E-Mail-Adresse als BCC hinzufügen + + // Inhalt + $mail->isHTML(true); // E-Mail im HTML-Format + $mail->Subject = 'Neue Nachricht vom Bestellformular der Website'; + $mail->Body = nl2br(htmlspecialchars($message)); + $mail->AltBody = htmlspecialchars($message); + + $mail->send(); + echo 'Nachricht wurde gesendet'; +} catch (Exception $e) { + echo "Nachricht konnte nicht gesendet werden. Fehler: {$mail->ErrorInfo}"; +} +?> diff --git a/public/php/message.php b/public/php/message.php new file mode 100644 index 0000000..e8e0922 --- /dev/null +++ b/public/php/message.php @@ -0,0 +1,95 @@ +