diff --git a/.gitignore b/.gitignore index c2e6b39..23e439c 100755 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ netlify.toml vercel.json vercel-build.sh .gitlab-ci.yml +static/php/mail.php # don't ignore public/php -!public/php \ No newline at end of file +!public/php diff --git a/static/php/ajaxmail.php b/static/php/ajaxmail.php new file mode 100644 index 0000000..00d7ef9 --- /dev/null +++ b/static/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/static/php/message.php b/static/php/message.php new file mode 100644 index 0000000..c73f888 --- /dev/null +++ b/static/php/message.php @@ -0,0 +1,117 @@ +