2024-01-19 13:10:24 +01:00
|
|
|
<?php
|
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
|
|
use PHPMailer\PHPMailer\Exception;
|
2024-01-19 13:22:08 +01:00
|
|
|
use PHPMailer\PHPMailer\SMTP;
|
|
|
|
|
|
|
|
require 'PHP/fichier/php/PHP/PHPMailer/src/Exception.php';
|
|
|
|
require 'PHP/fichier/php/PHP/PHPMailer/src/PHPMailer.php';
|
|
|
|
require 'PHP/fichier/php/PHP/PHPMailer/src/SMTP.php';
|
2024-01-19 13:10:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
|
|
$name = $_POST["name"];
|
|
|
|
$email = $_POST["email"];
|
|
|
|
$message = $_POST["message"];
|
|
|
|
$mail = new PHPMailer(true);
|
|
|
|
|
|
|
|
try {
|
|
|
|
// Paramètres du serveur SMTP
|
|
|
|
$mail->isSMTP();
|
|
|
|
$mail->Host = 'smtp.gmail.com';
|
|
|
|
$mail->SMTPAuth = true;
|
|
|
|
$mail->Username = 'neoeat.sav@gmail.com';
|
|
|
|
$mail->Password = 'zann afaj cnus tifc';
|
|
|
|
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
|
|
|
$mail->Port = 465;
|
|
|
|
|
|
|
|
|
|
|
|
$mail->setFrom($email, $name);
|
|
|
|
$mail->addAddress('neoeat.sav@gmail.com', 'Neo Eat');
|
|
|
|
|
|
|
|
|
|
|
|
$mail->isHTML(false);
|
2024-01-19 13:22:08 +01:00
|
|
|
$mail->Subject = 'Nouveau message client !';
|
2024-01-19 13:10:24 +01:00
|
|
|
$mail->Body = "Name: $name\nEmail: $email\nMessage:\n$message";
|
|
|
|
|
|
|
|
|
|
|
|
$mail->send();
|
|
|
|
header("Location: ../html/messageSucces.html");
|
|
|
|
} catch (Exception $e) {
|
|
|
|
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|