onRecordAfterCreateSuccess(function(e) { if (e.collection.name !== "inquiries") return; var key = $os.getenv("BREVO_KEY"); if (!key) { console.error("BREVO_KEY nicht gesetzt"); return; } var name = e.record.getString("name"); var company = e.record.getString("company"); var email = e.record.getString("email"); var phone = e.record.getString("phone"); var message = e.record.getString("message"); var plan = e.record.getString("plan"); var subject = "checkflo: Neue Anfrage von " + name + (company ? " (" + company + ")" : ""); var text = "Von: " + name + (company ? " / " + company : "") + "\nEmail: " + email + (phone ? "\nTel: " + phone : "") + (plan ? "\nPlan: " + plan : "") + (message ? "\nNachricht: " + message : ""); try { $http.send({ url: "https://api.brevo.com/v3/smtp/email", method: "POST", headers: { "api-key": key, "Content-Type": "application/json" }, body: JSON.stringify({ sender: { name: "checkflo", email: "hallo@checkflo.de" }, to: [{ email: "checkflo@motocamp.de" }], subject: subject, textContent: text }) }); } catch(err) { console.error("Brevo error: " + String(err)); } }, "inquiries");