<?php   
error_reporting(E_ALL);
ini_set('display_errors', 1);

require "PHPMailer/PHPMailer/PHPMailerAutoload.php";
?>
 
 <?php 
  $fieldd=$_POST['fieldd']; 
  $fieldc=$_POST['fieldc']; 
  if((isset($fieldd)) && (isset($fieldc)) && ($fieldc==$fieldd))
  {


    $name= $_POST['name'];
    $email= $_POST['email'];
    $phone = $_POST['phone'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    
    
    

     
    $from="tester@clouddreams.in";
    $subject = "General Enquiry Form";
    
    $mailcontent = '<table width=100% border=0 border-color:none cellspacing=3 cellpadding=3 class=text style="font-family:Arial; line-height:160% word-spacing:0.4em font-size:14px; border: 1px solid" bgcolor="#F9F9F9" color:"#465864">
    <tr >
    <td colspan="4"  align="center" bgcolor="#e0e1e1" ><strong >Contact Details From ' . $name . '</strong></td>
    </tr>

    <tr> <td>Name </td> <td> : </td> <td >' . $name . '</td> </tr>
    <tr> <td>Email </td> <td> : </td> <td>' . $email . '</td> </tr>
    <tr> <td>Mobile </td> <td> : </td> <td>' . $phone . '</td> </tr>
    <tr> <td>Subject </td> <td> : </td> <td>' . $subject . '</td> </tr>
    <tr> <td>Message </td> <td> : </td> <td>' . $message . '</td> </tr>
    </table>';

    
    $from_name="Chimney World";
    $to = "vel.clouddreams@gmail.com"; 

    
    

    function smtpmailer($to, $from, $subject, $body)
    {
        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->SMTPAuth = true; 
 
        $mail->SMTPSecure = ''; 
        $mail->Host = 'newdedi.clouddreams.in';
        $mail->Port = 25;  
        $mail->Username = 'tester@clouddreams.in';
        $mail->Password = 'OUHbP$W2$';    
        
    //   $path = "images/".$file_name;
    //   $mail->AddAttachment($path); 
   
        $mail->IsHTML(true);
        $mail->From= $from;
        $mail->FromName="Chimney Enquiry";
        $mail->Sender=$from; 
        $mail->Subject = $subject;
        $mail->Body = $body;
        $mail->AddAddress($to);
        if(!$mail->Send())
        {
            $error ="Your Mail not send but...";
            return $error; 
        }
        else 
        {
            $error = "Thanks You !! Your message is sent.";  
            return $error;
        }
    }
    $error=smtpmailer($to,$from ,$subject, $mailcontent);
    
    // $url="mail-success.html";
    // header("Location: ". $url);  
        echo "<script>window.location.href='mail-success.html';</script>";
    exit;
    
} else {
      // $url="mail-sent-error.html";
      // header("Location: " . $url);
        echo "<script>window.location.href='mail-sent-error.html';</script>";
}
?>