$maxSize) { return "Le fichier \"$label\" dépasse 5 Mo."; } $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); if (!in_array($ext, $exts)) { return "Format invalide pour \"$label\". Acceptés : PDF, DOC, DOCX, JPG, PNG."; } return null; } $errPJ1 = validerFichierOptional('pj1', 'Document 1', $maxFileSize, $allowedExts); $errPJ2 = validerFichierOptional('pj2', 'Document 2', $maxFileSize, $allowedExts); if ($errPJ1) { $erreur_form = $errPJ1; } elseif ($errPJ2) { $erreur_form = $errPJ2; } else { // Collecte des PJ présentes foreach (['pj1' => 'Document1', 'pj2' => 'Document2'] as $champ => $label) { if (isset($_FILES[$champ]) && $_FILES[$champ]['error'] === UPLOAD_ERR_OK) { $attachments[] = [ 'tmp' => $_FILES[$champ]['tmp_name'], 'name' => $label . '_' . $nom . '_' . $entreprise . '.' . strtolower(pathinfo($_FILES[$champ]['name'], PATHINFO_EXTENSION)), ]; } } // 5. PARAMÈTRES ENVOI $destinataires = ['webmaster@sapahabitat.com']; $expediteur = 'contact@sapahabitat.com'; $nomExpediteur = 'GROUPE SAPA – Cession société'; $objet = "Proposition cession – " . $entreprise . " – " . $nom . " " . $prenom; $corps = "NOUVELLE PROPOSITION DE CESSION DE SOCIÉTÉ\n"; $corps .= str_repeat("=", 40) . "\n\n"; $corps .= "Nom : $nom\n"; $corps .= "Prénom : $prenom\n"; $corps .= "Entreprise : $entreprise\n"; $corps .= "Téléphone : $tel\n"; $corps .= "E-mail : $email\n"; $corps .= "Code P. : $codepostal\n"; $corps .= "Ville : $ville\n\n"; $corps .= "Message :\n$message\n"; // 6. CONFIG SMTP $config = require __DIR__ . '/../config_smtp.php'; // 7. ENVOI MAIL PRINCIPAL $mail = new PHPMailer(true); $mail->CharSet = 'UTF-8'; $mail->Encoding = 'base64'; try { $mail->isSMTP(); $mail->Host = $config['host']; $mail->SMTPAuth = true; $mail->Username = $config['username']; $mail->Password = $config['password']; $mail->SMTPSecure = $config['encryption']; $mail->Port = $config['port']; $mail->setFrom($expediteur, $nomExpediteur); foreach ($destinataires as $dest) { $mail->addAddress(trim($dest)); } $mail->addReplyTo($email, "$prenom $nom"); $mail->Subject = $objet; $mail->isHTML(false); $mail->Body = $corps; foreach ($attachments as $att) { $mail->addAttachment($att['tmp'], $att['name']); } $mail->send(); $envoiOK = true; } catch (Exception $e) { $envoiOK = false; $erreur_form = "Erreur envoi SMTP : " . $mail->ErrorInfo; } // 8. MAIL DE CONFIRMATION if ($envoiOK) { $sujetConfirm = "Confirmation de votre prise de contact – GROUPE SAPA"; $corpsConfirm = "
GROUPE SAPA

Bonjour " . htmlspecialchars($prenom) . " " . htmlspecialchars($nom) . ",

Nous avons bien reçu votre proposition concernant la société " . htmlspecialchars($entreprise) . ".
Notre équipe étudiera votre dossier et reviendra vers vous dans les meilleurs délais.

Nous vous remercions de la confiance que vous accordez au GROUPE SAPA.

Cordialement,
L'équipe GROUPE SAPA

Cet e-mail a été envoyé automatiquement – merci de ne pas y répondre directement.
"; $mailC = new PHPMailer(true); $mailC->CharSet = 'UTF-8'; $mailC->Encoding = 'base64'; try { $mailC->isSMTP(); $mailC->Host=$config['host']; $mailC->SMTPAuth=true; $mailC->Username=$config['username']; $mailC->Password=$config['password']; $mailC->SMTPSecure=$config['encryption']; $mailC->Port=$config['port']; $mailC->setFrom($expediteur, $nomExpediteur); $mailC->addAddress($email, "$prenom $nom"); $mailC->Subject=$sujetConfirm; $mailC->isHTML(true); $mailC->Body=$corpsConfirm; $mailC->send(); } catch (Exception $e) { /* non bloquant */ } // 9. REDIRECTION SUCCÈS header('Location: https://www.groupe-sapa.fr/vendre-societe-recue.html'); exit; } } } } } // Génération du captcha (toujours) $code = rand(1000, 9999); $_SESSION['code'] = $code; ?> Vendre votre socièté
Facebook Linkedin Youtube