23 March 2021

Contact form mail submitted with images attachment and using the Gmail login credential 1

 <?php


$servername = "localhost";


$username = "root";


$password = " ";


$dbname = "indra";


// Create connection


$conn = new mysqli($servername, $username, $password, $dbname);


  $Name = $_REQUEST['Name'] ;


  $Mobile_No = $_REQUEST['Mobile_No'] ;


  $City = $_REQUEST['City'] ;


  $Recipe_Name = $_REQUEST['Recipe_Name'] ;


  $files = $_FILES['Recipe_Data'];


  $file_upload = $_FILES['Sweets_Photo'];


  $new1 = str_replace(' ', '_', basename($_FILES['Recipe_Data']['name']));


   $file = '';


  $new1 = str_replace(' ', '_', basename($_FILES['Recipe_Data']['name']));


  $path1 ="http://jagranlive.in/indrajeet/uploads/".$new1;


  $newname1=$path1;


  $target_path = 'uploads/';


  move_uploaded_file($_FILES['Recipe_Data']['tmp_name'],$target_path.$new1);


  $new2 = str_replace(' ', '_', basename($_FILES['Sweets_Photo']['name']));


  $path2 ="http://jagranlive.in/indrajeet/uploads/".$new2;


  $newname=$path2;


  $target_path = 'uploads/';


  move_uploaded_file($_FILES['Sweets_Photo']['tmp_name'],$target_path.$new2);


 $sql = "INSERT INTO enquiry (Name, Mobile_No, City, Recipe_Name, Recipe_Data,Sweets_Photo) VALUES ('".$Name."', '".$Mobile_No."', '".$City."','".$Recipe_Name."','".$newname1."','".$newname."')";


if ($conn->query($sql) === TRUE) {


  echo "New record created successfully";


}


else {


  echo "Error: " . $sql . "<br>" . $conn->error;


}


$conn->close();


    require_once('mailer/class.smtp.php');

    include_once('mailer/class.phpmailer.php');


    

    $mail = new PHPMailer();

    $mail->CharSet =  "utf-8";

    $mail->IsSMTP();

    $mail->SMTPAuth = true;

    $mail->SMTPDebug = 0;

    $mail->SMTPOptions = array(

    'ssl' => array(

    'verify_peer' => false,

    'verify_peer_name' => false,

    'allow_self_signed' => true

    )

    );

    $mail->Username = "noreply@jagranlive.in";

    $mail->Password = "wAw+M=[4)GYH";

    $mail->SMTPSecure = "ssl";  

    $mail->Host = "mail.jagranlive.in";

    $mail->Port = "465";

    $mail->FromName = "Enquiry From $Name";

   $mail->AddAddress('Indra.jagran@gmail.com', 'Jagran');

/*  $mail->AddAddress('Indra422@gmail.com', 'Jagran');*/

    $mail->Subject = "Milkmaid";

    foreach ($newname1["name"] as $k => $v) {

        $mail->AddAttachment( $newname1["tmp_name"][$k], $newname1["name"][$k] );

    }

    foreach ($newname["name"] as $k => $v) {

        $mail->AddAttachment( $newname["tmp_name"][$k], $newname["name"][$k] );

    }

    $mail->IsHTML(true);

    $mail->Body    = " <html><body>

    <div id='page-wrap' style='margin: 0 auto; width:800px; background-color: #fff; border: 1px solid #ccc; padding:20px;'>


                  <table width='100%' cellpadding='0' cellspacing='0' border='0' style='padding:20px; margin-top: 20px;'>

      <tbody>

                <tr>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc; text-transform:uppercase;'>Name</td>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc;'>".$Name."</td>

                  </tr>

                  <tr>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc; text-transform:uppercase;'>Mobile_No No.</td>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc;'>".$City."</td>

            </tr>

                <tr>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc; text-transform:uppercase;'>City</td>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc;'>".$Mobile_No."</td>

            </tr>

            

           

           <tr>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc; text-transform:uppercase;'>Recipe Name<br></td>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc;'>".$Recipe_Name."</td>

           </tr>

           

            <tr>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc; text-transform:uppercase;'>Recipe Name<br></td>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc;'>".$Recipe_Name."</td>

           </tr>

            <tr>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc; text-transform:uppercase;'>Recipe Data<br></td>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc;'>".$newname1."</td>

           </tr>

            <tr>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc; text-transform:uppercase;'>Sweets Picturee<br></td>

            <td style='padding: 10px 20px 10px 20px; color:#020844; font-size: 16px; border:1px solid #ccc;'>".$newname."</td>

           </tr>

                      </tbody>

                    </table>

                    

                </div>

                </body></html>";



if(!$mail->send()) {

  echo 'Message was not sent.';

  echo 'Mailer error: ' . $mail->ErrorInfo;

  exit;

}

echo <<<HTML

<!DOCTYPE html>

<html lang="en">


<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Milkmaid</title>


    <meta name="keywords" content="" />

    <meta name="author" content="MarkSerif" />


    <!-- bootstrap v4 css -->

    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">

    <!-- style css -->

    <link rel="stylesheet" type="text/css" href="css/style.css">

    <!-- responsive css -->

    <link rel="stylesheet" type="text/css" href="css/responsive.css">

</head>


<body>

    <div class="page-wrapper">

        <section class="top_section-desktop d-none d-xl-block">

            <div class="container-fluid">

                <div class="row d-flex align-items-center">

                    <div class="col-6 d-flex justify-content-start logo-1">

                        <img src="images/Nestle-Milkmaid--Logo.png">

                    </div>


                    <div class="col-6 d-flex justify-content-end logo-2">

                        <img src="images/Logo.png">

                    </div>

                    <div class="col-12 about-us-hedding">

                        <div class="col-12 caption-img center">

                            <img src="images/heading-img.png">

                        </div>

                    </div>

                </div>

            </div>

        </section>

        <section class="top_section d-xl-none">

            <div class="container-fluid">

                <div class="row d-flex align-items-center">

                    <div class="col-6 logo-1">

                        <img src="images/Nestle-Milkmaid--Logo.png">

                    </div>

                    <div class="col-6 d-flex justify-content-end logo-2">

                        <img src="images/Logo.png">

                    </div>

                    <div class="col-12 caption-img-Mobile_No center">

                        <img src="images/Mobile_No-headding.png" class="w-100">

                    </div>


                </div>

            </div>

        </section>

        <section class="main-content">

            <div class="heading">

                <div class="container-fluid">

                    <div class="row">                        

                        <div class="col-3 d-none d-sm-block"></div>

                        <div class="col-3">

                            <div class="holi-color d-none d-xl-block d-md-block">

                            </div>

                        </div>

                        <div class="col-12 col-md-12 col-xl-6 col-lg-6">

                            <div class="thankyou-content">

                                <h3>आपकी मनपसन्द मिठाई की रेसिपी भेजने के लिए सादर धन्यवाद। हम जल्द ही आपसे संपर्क करेंगे। Nestlé Milkmaid और दैनिक जागरण की ओर से 

                                    होली की हार्दिक शुभकामनाएँ।</h3>

                            </div>

                        </div>

                    </div>

                </div>

            </div>

        </section>

    </div>

    <script src="js/jquery.min.js"></script>

    <!-- bootstrap js -->

    <script src="js/bootstrap.min.js"></script>

</body>


</html>

HTML;

?>