diff --git a/SRC/contact.php b/SRC/contact.php new file mode 100644 index 0000000..adc56d9 --- /dev/null +++ b/SRC/contact.php @@ -0,0 +1,102 @@ +Format non autorisé. Seuls les fichiers JPG, PNG et PDF sont acceptés.
"; + $has_error = true; + } elseif ($file_size > $max_size) { + $message_status = "Le fichier est trop volumineux (maximum 5 Mo).
"; + $has_error = true; + } else { + $content = file_get_contents($file_tmp_name); + $encoded_content = chunk_split(base64_encode($content)); + + $attachment = "Content-Type: $file_type; name=\"$file_name\"\r\n"; + $attachment .= "Content-Disposition: attachment; filename=\"$file_name\"\r\n"; + $attachment .= "Content-Transfer-Encoding: base64\r\n\r\n"; + $attachment .= $encoded_content . "\r\n\r\n"; + } + } + + if (!$has_error) { + // Générer une frontière (boundary) unique pour séparer le texte de la pièce jointe + $boundary = md5(uniqid(time())); + + $headers = "From: $email\r\nReply-To: $email\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"$boundary\"\r\n"; + + $body = "--$boundary\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\n"; + $body .= "Email: $email\nObjet: $subject\n\nDemande:\n$message\r\n\r\n"; + + if (!empty($attachment)) { + $body .= "--$boundary\r\n" . $attachment; + } + $body .= "--$boundary--\r\n"; + + if (@mail($to, $subject, $body, $headers)) { + $message_status = "Votre message a été envoyé avec succès !
"; + } else { + $message_status = "Erreur lors de l'envoi du message. Veuillez vérifier la configuration de votre serveur.
"; + } + } +} +?> + + + + +