fix: contact form — email fallback + non-fatal Telegram
- Always send email to info@sag24.ru (via server mail()) - Return success even if Telegram is unreachable (ТСПУ blocks 45.10.53.x) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,9 +56,15 @@ $result = curl_exec($ch);
|
|||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
if ($httpCode === 200) {
|
// 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]);
|
echo json_encode(['success' => true]);
|
||||||
} else {
|
|
||||||
http_response_code(500);
|
|
||||||
echo json_encode(['error' => 'Failed to send notification']);
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user