diff --git a/contact.html b/contact.html
index f029621..bc567be 100644
--- a/contact.html
+++ b/contact.html
@@ -280,6 +280,7 @@
+
diff --git a/js/form-handler.js b/js/form-handler.js
index 9e59354..8d41d43 100644
--- a/js/form-handler.js
+++ b/js/form-handler.js
@@ -8,6 +8,16 @@ const HUBSPOT_PORTAL_ID = '148163754';
const HUBSPOT_FORM_GUID = '1d9b75c9-8b60-4966-aa18-4bf503452e9a';
const FORMSPREE_ID = 'mojrvokp';
+// ── EMAILJS (email de bienvenue au client) ────────────────────────────────────
+const EMAILJS_PUBLIC_KEY = '8KUlaQ7BDVlbkZRyP';
+const EMAILJS_SERVICE_ID = 'service_o1yv09o';
+const EMAILJS_TEMPLATE_ID = 'yx7jdwi';
+
+// Initialisation EmailJS (une seule fois au chargement)
+if (typeof emailjs !== 'undefined') {
+ emailjs.init({ publicKey: EMAILJS_PUBLIC_KEY });
+}
+
// ── PROXY CLOUDFLARE WORKER ───────────────────────────────────────────────────
// URL du Worker qui proxifie l'API HubSpot CRM (contourne le CORS).
// Après déploiement du Worker (voir cloudflare-worker/hubspot-proxy.js),
@@ -94,7 +104,7 @@ function setupContactForm(form) {
setLoading(false);
if (hubspotOk || formspreeOk) {
- showSuccess(refNumber);
+ showSuccess(refNumber, data);
} else {
showError();
}
@@ -248,7 +258,7 @@ function setLoading(isLoading) {
form?.classList.toggle('form-loading', isLoading);
}
-function showSuccess(refNumber) {
+function showSuccess(refNumber, clientData) {
const successEl = document.getElementById('formSuccess');
const form = document.getElementById('contactForm');
const refDisplay = document.getElementById('refNumberDisplay');
@@ -258,6 +268,24 @@ function showSuccess(refNumber) {
successEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
if (form) form.style.display = 'none';
+
+ // Envoi de l'email de bienvenue au client (sans bloquer l'affichage)
+ if (clientData) sendWelcomeEmail(clientData);
+}
+
+// ── EMAIL DE BIENVENUE ────────────────────────────────────────────────────────
+async function sendWelcomeEmail(data) {
+ if (typeof emailjs === 'undefined') return;
+ try {
+ await emailjs.send(EMAILJS_SERVICE_ID, EMAILJS_TEMPLATE_ID, {
+ firstname: data.firstname,
+ email: data.email,
+ reference_client: data.reference_client,
+ });
+ } catch (err) {
+ // L'email de bienvenue est un bonus — on ne bloque pas l'inscription si ça échoue
+ console.warn('EmailJS welcome email failed:', err);
+ }
}
// Affiche le message "déjà client" — ne modifie AUCUNE donnée HubSpot