diff --git a/public/api/contact.php b/public/api/contact.php index d6d7093..2037451 100644 --- a/public/api/contact.php +++ b/public/api/contact.php @@ -56,9 +56,15 @@ $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); -if ($httpCode === 200) { - echo json_encode(['success' => true]); -} else { - http_response_code(500); - echo json_encode(['error' => 'Failed to send notification']); -} +// Email fallback (always send, regardless of Telegram result) +$subject = "Заявка с сag24.ru от {$name}"; +$body = "Имя: {$name}\n"; +if ($phone) $body .= "Телефон: {$phone}\n"; +if ($email) $body .= "Email: {$email}\n"; +$body .= "\nСообщение:\n{$message}\n"; +$body .= "\n" . date('d.m.Y H:i', time() + 3 * 3600) . " MSK"; +$headers = "From: noreply@sag24.ru\r\nContent-Type: text/plain; charset=UTF-8"; +mail('info@sag24.ru', $subject, $body, $headers); + +// Return success regardless of Telegram result +echo json_encode(['success' => true]);