isSMTP(); //Enable SMTP debugging //SMTP::DEBUG_OFF = off (for production use) //SMTP::DEBUG_CLIENT = client messages //SMTP::DEBUG_SERVER = client and server messages $mail->SMTPDebug = SMTP::DEBUG_OFF; //Set the hostname of the mail server $mail->Host = 'smtp-mail.outlook.com'; //Set the SMTP port number - likely to be 25, 465 or 587 $mail->Port = 587; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication $mail->Username = 'edms@premiummegastructures.com'; //Password to use for SMTP authentication $mail->Password = 'oB4n4n4357'; //Set who the message is to be sent from $mail->setFrom('edms@premiummegastructures.com', 'Vault Management'); //Set an alternative reply-to address $mail->addReplyTo('edms@premiummegastructures.com', 'Vault Management'); //Set who the message is to be sent to include '../config.php'; // $reqid=$_GET['id']; $id = $_GET['id']; $doc_id = $_GET['doc_id']; $user_id = $_GET['user_id']; $rtype =$_GET['type']; $reqtype = $rtype; $sql = "SELECT files.web_path FROM request LEFT JOIN documents ON request.document = documents.id LEFT JOIN files ON documents.file = files.id WHERE request.id = $id"; $result = $conn->query($sql); $row = $result->fetch_assoc(); $filepath = $row['web_path']; $view_file = '..'.$filepath; // Replace this with the actual source file path $destination_folder = "../temp_files/"; // Replace this with the actual destination folder path if (file_exists($view_file)) { // Get the filename from the source file path $filename = basename($view_file); // Generate a unique 3-letter code $uniqueCode = strtoupper(substr(md5(uniqid(rand(), true)), 0, 3)); // Add the code to the filename $newFilename = $filename . '_' . $uniqueCode ; // Create the destination file path by combining the destination folder path and the new filename $destinationFilePath = $destination_folder . $newFilename; // Copy the file from source to destination if (copy($view_file, $destinationFilePath)) { echo "File copied successfully!"; } else { echo "Failed to copy the file."; } } else { echo "Source file not found."; } $sql = "UPDATE request SET status=3 WHERE id=$id"; $result = $conn->query($sql); $uid = uniqid(); // $cur_date = date('Y-m-d'); // // $exp_date = date('Y-m-d', strtotime('+1 day')); // $exp_date = new DateTime(); // $exp_date->modify('+24 hours'); // $exp_date = $exp_date->format('Y-m-d'); $cur_date = date('Y-m-d H:i:s'); // Get the current date and time $exp_date = new DateTime($cur_date); // Create a new DateTime object with the current date and time $exp_date->modify('+24 hours'); // Add 24 hours to the DateTime object $exp_date = $exp_date->format('Y-m-d H:i:s'); // Format the DateTime object as 'Y-m-d H:i:s' and store it in $exp_date $deleted = 0; if($result){ echo "Success!"; if ($reqtype == 0) { $sql_insert = "INSERT INTO file_expire (req_id, doc_id, temp, deleted, uid, cur_date, exp_date) VALUES ($id, $doc_id, '$destinationFilePath' ,$deleted, '$uid', '$cur_date', '$exp_date')"; $result_insert = $conn->query($sql_insert); } } $sql = "SELECT * FROM vault_users WHERE id=$user_id"; $result = $conn->query($sql); $row = $result->fetch_assoc(); $user_mail = $row['email']; $user_name = $row['name']; $role = $row['role']; $mail->addAddress("$user_mail", "$user_name"); //Set the subject line $mail->Subject = "Request Released"; if ($reqtype == 0) { $uri = "http://172.17.0.8/templates/release.php?user_id=$user_id&doc_id=$doc_id&reqid=$id&uid=$uid"; $mail->msgHTML(file_get_contents("$uri"), __DIR__); }elseif ($reqtype == 1){ $uri = "http://172.17.0.8/templates/releaseCopy.php?user_id=$user_id&doc_id=$doc_id"; $mail->msgHTML(file_get_contents("$uri"), __DIR__); }elseif ($reqtype == 2){ $uri = "http://172.17.0.8/templates/releaseOC.php?user_id=$user_id&doc_id=$doc_id"; $mail->msgHTML(file_get_contents("$uri"), __DIR__); } //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body // $uri = "http://172.17.0.5/templates/release.php?user_id=$user_id&doc_id=$doc_id"; // $mail->msgHTML(file_get_contents("$uri"), __DIR__); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //Attach an image file //$mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message sent!'; header("Location: " . $_SERVER["HTTP_REFERER"]); }