Current Directory: /home/aissorg/public_html
Viewing File: /home/aissorg/public_html/contact-mail.php
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
if (isset($_POST['contact-us'])) {
// Collecting form data
$title = $_POST['title'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = nl2br($_POST['message']); // To preserve line breaks
$fullName = trim($fname . ' ' . $lname);
// Email body
$htmlBody = '
<div style="font-family: Arial, sans-serif; font-size:14px;">
<h2>Enquiry From Website</h2>
<p><strong>Title:</strong> ' . htmlspecialchars($title) . '</p>
<p><strong>Name:</strong> ' . htmlspecialchars($fullName) . '</p>
<p><strong>Email:</strong> ' . htmlspecialchars($email) . '</p>
<p><strong>Phone:</strong> ' . htmlspecialchars($phone) . '</p>
<p><strong>Message:</strong><br>' . $message . '</p>
</div>';
// Setup PHPMailer
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'v22437909.sin01.serveradd.com';
$mail->SMTPAuth = true;
$mail->Username = 'admin@aiss.org.in';
$mail->Password = 'Oo(hKvdR.52E';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('admin@aiss.org.in', 'Sai Baba Temple Website');
$mail->addAddress('kavintechsolutions@gmail.com'); // Send to admin
//$mail->addAddress('periyasamyanbu@gmail.com'); // Send to admin
$mail->addReplyTo($email, $fullName); // Reply to sender
$mail->isHTML(true);
$mail->Subject = "Contact Form Submission - " . $title;
$mail->Body = $htmlBody;
$mail->send();
echo "<script>alert('Your message has been sent successfully.'); window.location.href='index.php';</script>";
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
?>