superflux/contact.php

82 lines
2.7 KiB
PHP
Executable File

<?php include "debut.inc.php"; ?>
<br>
<form method="POST" action="contact.php">
Si vous souhaitez me contacter, vous pouvez laisser un message ci-dessous ou m'envoyer directement un courriel à <a href="mailto:cecile+superflux@antopie.org">cecile+superflux@antopie.org</a>.
<br>
<br>
<label for="message">Votre message :</label>
<br>
<textarea name="message" rows="10" style="width: 85%;" title="10 000 caractères maximum" placeholder="Bonjour," maxlength="10000" type="text"></textarea>
<br>
<label for="captcha">Combien font cinq plus trois ?</label>
<br>
<input id="captcha" required="" type="text" name="captcha" />
<br>
<input value="Envoyer" type="submit"><br>
</form>
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
if (isset($_POST['message'])) {
if (strlen($_POST['message']) <= 10000) {
if (strtolower($_POST['captcha']) == "huit" OR $_POST['captcha'] == 8) {
$mail = new PHPMailer(true);
try {
require "mdp.php";
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'yuno.antopie.org'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'send@antopie.org'; // SMTP username
$mail->Password = $mdp; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('send@antopie.org', 'Super·F·lux');
$mail->addAddress('cecile+superflux@antopie.org', 'Cécile CHEVALLIER'); // Add a recipient
//$mail->addReplyTo($_POST['email'], $_POST['nom']);
// Content
$mail->CharSet = 'UTF-8';
$mail->isHTML(false);
$mail->Subject = "Message depuis le site Web de Super·F·lux";
$mail->Body = htmlspecialchars(substr($_POST['message'], 0, 20000));
$mail->send();
echo "Le message a bien été envoyé !";
} catch (Exception $e) {
echo "Le message n'a pas pu être envoyé. Mailer Error: {$mail->ErrorInfo}";
}
} else {
echo "Erreur : Captcha invalide !";
}
} else {
echo "ERREUR : Le message fait plus de 10 000 caractères !";
}
}
?>
<?php include "fin.inc.php"; ?>