200) { $errors[] = "Name is too long."; } // Validate email if ($posted_email === '') { $errors[] = "Email is required."; } elseif (!filter_var($posted_email, FILTER_VALIDATE_EMAIL)) { $errors[] = "Please enter a valid email address."; } elseif (mb_strlen($posted_email) > 200) { $errors[] = "Email is too long."; } // Validate message if ($posted_message === '') { $errors[] = "Message is required."; } elseif (mb_strlen($posted_message) > 8000) { $errors[] = "Message is too long."; } // If no errors, prepare and send email if (empty($errors)) { // Gather metadata $ip = $_SERVER['REMOTE_ADDR'] ?? 'Unknown'; $ua = $_SERVER['HTTP_USER_AGENT'] ?? 'Unknown'; $received_at = date('Y-m-d H:i:s'); // Subject and Body (UTF-8 safe) $subject = "New message from Tamil Font Converter - " . mb_substr($posted_name, 0, 50); $body = "You have received a new message from the contact form on your site.\r\n\r\n"; $body .= "Name: " . $posted_name . "\r\n"; $body .= "Email: " . $posted_email . "\r\n"; $body .= "IP Address: " . $ip . "\r\n"; $body .= "User Agent: " . $ua . "\r\n"; $body .= "Received At: " . $received_at . "\r\n\r\n"; $body .= "Message:\r\n" . $posted_message . "\r\n"; // Proper headers for UTF-8 and reply-to $from_domain = $_SERVER['HTTP_HOST'] ?? 'example.com'; // Use a safe From address on your domain to avoid spam flags: e.g. noreply@yourdomain.com $from_address = 'noreply@' . $from_domain; $headers = "From: Tamil Font Converter <" . $from_address . ">\r\n"; $headers .= "Reply-To: " . $posted_email . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/plain; charset=UTF-8\r\n"; // Try to send email (suppressed @ to avoid warnings in UI) $mail_sent = @mail($recipient_email, $subject, $body, $headers); if ($mail_sent) { $success = true; // Update last send time for rate-limiting $_SESSION['last_contact_time'] = $now; // Clear posted values to empty the form $posted_name = $posted_email = $posted_message = ''; } else { $errors[] = "Failed to send email. The message wasn't delivered. Check your server mail settings or use SMTP."; } } } } ?>
Have questions, feedback, or issues with Tamil Font Converter? We’d love to hear from you. Reach us anytime using the details below.
📧 Email us at: