<?php
session_start();
/*require 'PHPMailer/PHPMailer/PHPMailerAutoload.php';*/
require 'extensions/extensions/class.phpmailer.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    //echo"<pre>"; print_r($_POST);exit;
    $name = $_POST['name'];
    $mobile = $_POST['mobile'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];

    // Validate input data (additional server-side validation can be added)

    if (empty($name) || empty($mobile) || empty($email) || empty($subject) || empty($message)) {
        echo "All fields are required.";
        exit();
    }

    // Configure PHPMailer
    

    $mail = new PHPMailer;
	$mail->setFrom('mamasmile.penguin@gmail.com', 'Mama Smile Penguins');
    //$mail->setFrom($email, $name); // Replace with your Gmail address and your name
    $mail->addAddress('preetimahijpr@gmail.com', 'Vimla Sharma'); // Replace with the recipient's email address and name
    //$mail->addAddress('mamasmile.penguin@gmail.com', 'Vimla Sharma'); // Replace with the recipient's email address and name
    $mail->Subject = 'New Contact Form Submission: ' . $subject;
    $mail->Body = "Name: $name\n\nMobile: $mobile\n\nEmail: $email\n\nMessage: $message";
// Enable debugging
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
    // Send email
    if ($mail->send()) {
        $_SESSION['msg']='ok';
        header('location:index.php');
       // echo 'Message sent successfully.';
    } else {
        $_SESSION['msg']='fail';
        header('location:index.php');
       // echo 'An error occurred while sending the message: ' . $mail->ErrorInfo;
    }
}
?>
