65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Contact form endpoint → solutions@zettaisystems.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/helpers.php';
|
|
|
|
zs_require_post();
|
|
|
|
if (zs_is_honeypot_filled()) {
|
|
zs_json_response(200, ['ok' => true, 'message' => 'Thank you. We have received your message.']);
|
|
}
|
|
|
|
zs_require_csrf();
|
|
zs_rate_limit('contact');
|
|
|
|
$name = zs_field('name', 120);
|
|
$email = zs_field('email', 160);
|
|
$phone = zs_field('phone', 40);
|
|
$company = zs_field('company', 160);
|
|
$service = zs_field('service', 120);
|
|
$subject = zs_field('subject', 200);
|
|
$message = zs_field('message', 5000);
|
|
|
|
if ($subject === '') {
|
|
$subject = 'Website enquiry';
|
|
}
|
|
|
|
if ($name === '' || $email === '' || $message === '') {
|
|
zs_json_response(400, ['ok' => false, 'error' => 'Please fill in all required fields.']);
|
|
}
|
|
if (!zs_valid_email($email)) {
|
|
zs_json_response(400, ['ok' => false, 'error' => 'Please enter a valid email address.']);
|
|
}
|
|
|
|
$mailSubject = '[Contact] ' . $subject;
|
|
$body = "New contact enquiry from the Zettai Systems website\n";
|
|
$body .= str_repeat('-', 48) . "\n\n";
|
|
$body .= "Name: {$name}\n";
|
|
$body .= "Email: {$email}\n";
|
|
$body .= "Phone: " . ($phone !== '' ? $phone : '—') . "\n";
|
|
$body .= "Company: " . ($company !== '' ? $company : '—') . "\n";
|
|
$body .= "Service interest: " . ($service !== '' ? $service : '—') . "\n";
|
|
$body .= "Subject: {$subject}\n\n";
|
|
$body .= "Message:\n{$message}\n\n";
|
|
$body .= str_repeat('-', 48) . "\n";
|
|
$body .= 'Submitted: ' . gmdate('Y-m-d H:i:s') . " UTC\n";
|
|
$body .= 'IP: ' . ($_SERVER['REMOTE_ADDR'] ?? 'unknown') . "\n";
|
|
|
|
$sent = zs_send_mail(ZS_CONTACT_TO, $mailSubject, $body, $email);
|
|
|
|
if (!$sent) {
|
|
zs_json_response(500, [
|
|
'ok' => false,
|
|
'error' => 'We could not send your message right now. Please email solutions@zettaisystems.com or try again later.',
|
|
]);
|
|
}
|
|
|
|
zs_json_response(200, [
|
|
'ok' => true,
|
|
'message' => 'Thank you. Your message has been sent. We will get back to you soon.',
|
|
]);
|