<?php

require_once ('PHPMailer_5.2.0/class.phpmailer.php');


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

// $resume = $_POST["resume"];

// $resume_file = $_FILES["resume-file"];
// $resume_name  = $resume_file['name'];
// ob_start(); ?>
 <html>
     <head>
       <title>Apply</title>
     </head>
     <body>
          <table>
                <tr>
                    <td>Name:</td>
                    <td><?php echo $name; ?></td>
                </tr>
                <tr>
                    <td>Email:</td>
                    <td><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></td>   
                </tr>
                
                <tr>
                    <td>Message:</td>
                    <td><?php echo $message;  ?></td>
                </tr>          
            
            </table> 
       </body>
    </html> 
<?php

 $msg = ob_get_clean(); 


$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP

$mail->SMTPAuth = true;   
$mail->SMTPSecure = "tls";               // enable SMTP authentication
$mail->Host = "mail.dilig.net";
$mail->Port = 587;
$mail->Username  = "contactus@dilig.net"; // SMTP username
$mail->Password  = "contactus#dlgnt";     // SMTP password
$mail->SetFrom($email, $name);
    

$mail->Subject = $subject;

$mail->Body = $msg;

$mail->AddAddress('nikola.ignjatovic@dilig.net', "HR Diligent");
$mail->IsHtml(true);

$mail->send();


echo  json_encode("succesfull");
?>