Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$response = array('status' => '', 'message' => '');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$subject = htmlspecialchars($_POST['subject']);
$message = nl2br(htmlspecialchars($_POST['message']));
$mail = new PHPMailer(true);
try {
// Server instellingen
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com'; // SMTP-server van je e-mailprovider
$mail->SMTPAuth = true;
$mail->Username = 'othmaneaissaoui2020@gmail.com'; // SMTP-gebruikersnaam
$mail->Password = 'alipcduklnypoyop'; // SMTP-wachtwoord
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
// Ontvangers
$mail->setFrom($email, $name);
$mail->addAddress('othmaneaissaoui2020@gmail.com');
$mail->addReplyTo($email);
// Inhoud
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = "Naam: $name<br>Email: $email<br>Bericht: $message";
$mail->AltBody = "Naam: $name\nEmail: $email\nBericht: $message";
$mail->send();
$response['status'] = 'success';
$response['message'] = 'Bericht is verstuurd';
} catch (Exception $e) {
$response['status'] = 'error';
$response['message'] = "Bericht kon niet worden verstuurd. Mailer Error: {$mail->ErrorInfo}";
}
} else {
$response['status'] = 'error';
$response['message'] = 'Ongeldige aanvraagmethode.';
}
echo json_encode($response);