Contact

/** * Shortcode:
* Sends with wp_mail() (FluentSMTP handles From: info@jcc.lk) * To: jayathissapvt@gmail.com | Bcc: info@jcc.lk * Uses PRG (redirect to ?sent=1) to avoid 404 / resubmits. */ add_shortcode(‘jl_contact_form’, function () { $errors = []; $sent = (isset($_GET[‘sent’]) && $_GET[‘sent’] === ‘1’); $page_url = get_permalink(); if ($_SERVER[‘REQUEST_METHOD’] === ‘POST’ && isset($_POST[‘jlcf_submit’])) { // Nonce if (!isset($_POST[‘jlcf_nonce’]) || !wp_verify_nonce($_POST[‘jlcf_nonce’], ‘jlcf_send’)) { $errors[] = ‘Security check failed. Please reload and try again.’; } // Honeypot (should be empty) if (!empty($_POST[‘company’])) { $errors[] = ‘Spam detected.’; } // Sanitize $name = sanitize_text_field($_POST[‘name’] ?? ”); $email = sanitize_email($_POST[’email’] ?? ”); $phone = sanitize_text_field($_POST[‘phone’] ?? ”); $subject = sanitize_text_field($_POST[‘subject’] ?? ”); $message = wp_kses_post($_POST[‘message’] ?? ”); // Validate if ($name === ”) $errors[] = ‘Your name is required.’; if (!is_email($email)) $errors[] = ‘A valid email is required.’; if (trim(wp_strip_all_tags($message)) === ”) $errors[] = ‘Please type your message.’; if (empty($errors)) { // Recipients $to = [‘jayathissapvt@gmail.com’]; // Subject $site = wp_specialchars_decode(get_bloginfo(‘name’), ENT_QUOTES); $final_subject = ($subject !== ” ? $subject : ‘Website Contact’) . ” — {$site}”; // Body $body = “Name: ” . esc_html($name) . “
“; $body .= “Email: ” . esc_html($email) . “
“; if ($phone) $body .= “Phone: ” . esc_html($phone) . “
“; $body .= “
“; $body .= wpautop(wp_kses_post($message)); // Headers (FluentSMTP sets From: info@jcc.lk) $headers = [ ‘Content-Type: text/html; charset=UTF-8’, ‘Reply-To: ‘ . $name . ‘ <' . $email . '>‘, ‘Bcc: info@jcc.lk’, // remove if you don’t want a copy ]; if (wp_mail($to, $final_subject, $body, $headers)) { wp_safe_redirect( add_query_arg(‘sent’, ‘1’, $page_url) ); exit; } else { $errors[] = ‘Sending failed. Please try again later.’; } } } // Refill values on error $val = function($key){ return isset($_POST[$key]) ? esc_attr($_POST[$key]) : ”; }; $valtxt = function($key){ return isset($_POST[$key]) ? esc_textarea(wp_strip_all_tags($_POST[$key])) : ”; }; ob_start(); ?>

Contact Us

We usually reply within one business day.

‘.esc_html($e).’

‘; ?>
Thank you! Your message has been sent successfully.