File "sendEmail.php"

Full Path: /home/chawlag2/public_html/bikes/assets/vendor/swiper/sendEmail.php
File size: 2.11 KB
MIME-type: text/x-php
Charset: utf-8

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Sanitize form inputs
    $title = htmlspecialchars($_POST['title']);
    $fname = htmlspecialchars($_POST['fname']);
    $lname = htmlspecialchars($_POST['lname']);
    $email = htmlspecialchars($_POST['email']);
    $phone = htmlspecialchars($_POST['phone']);
    $business = htmlspecialchars($_POST['business']);
    $address = htmlspecialchars($_POST['address']);
    $years = htmlspecialchars($_POST['years']);
    $OEMDealer = htmlspecialchars($_POST['OEMDealer']);
    $province = htmlspecialchars($_POST['province']);
    $city = htmlspecialchars($_POST['city']);
    $ownership = htmlspecialchars($_POST['ownership']);
    $structure = htmlspecialchars($_POST['structure']);
    
    // Recipient email address
    $to = "syedzeeshanali38@gmail.com";

    // Subject of the email
    $subject = "New Form Submission";

    // Email content
    $message = "
    <html>
    <head>
        <title>Form Submission</title>
    </head>
    <body>
        <h2>Form Details</h2>
        <p><strong>Title:</strong> $title</p>
        <p><strong>First Name:</strong> $fname</p>
        <p><strong>Last Name:</strong> $lname</p>
        <p><strong>Email:</strong> $email</p>
        <p><strong>Phone:</strong> $phone</p>
        <p><strong>Business Name:</strong> $business</p>
        <p><strong>Address:</strong> $address</p>
        <p><strong>Years in Business:</strong> $years</p>
        <p><strong>OEM Dealer:</strong> $OEMDealer</p>
        <p><strong>Province:</strong> $province</p>
        <p><strong>City:</strong> $city</p>
        <p><strong>Property Ownership:</strong> $ownership</p>
        <p><strong>Structure:</strong> $structure</p>
    </body>
    </html>
    ";

    // Headers
    $headers  = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    $headers .= "From: <info@extensivetraders.com>" . "\r\n";

    // Send email
    if (mail($to, $subject, $message, $headers)) {
        echo "Email sent successfully!";
    } else {
        echo "Failed to send email.";
    }
}
?>