chore: code styling via pint
This commit is contained in:
23
dropmail.php
23
dropmail.php
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
// 1. Bootstrap Laravel
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__ . '/bootstrap/app.php';
|
||||
// 1. Bootstrap Laravel
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
// 2. Start Laravel container
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
@@ -24,23 +25,23 @@ $password = $imapDB['password'];
|
||||
$inbox = imap_open($hostname, $username, $password);
|
||||
|
||||
// Check for connection errors
|
||||
if (!$inbox) {
|
||||
die('Could not connect to mailbox: ' . imap_last_error());
|
||||
if (! $inbox) {
|
||||
exit('Could not connect to mailbox: '.imap_last_error());
|
||||
}
|
||||
|
||||
// Get current time in Unix timestamp
|
||||
$current_time = time();
|
||||
|
||||
// Search for messages older than one day
|
||||
//$search_criteria = 'BEFORE "' . date('d-M-Y', strtotime('-3 hours', $current_time)) . '"';
|
||||
//$messages = imap_search($inbox, $search_criteria);
|
||||
// $search_criteria = 'BEFORE "' . date('d-M-Y', strtotime('-3 hours', $current_time)) . '"';
|
||||
// $messages = imap_search($inbox, $search_criteria);
|
||||
|
||||
$messages = imap_search($inbox, 'ALL');
|
||||
|
||||
$batch_size = 10;
|
||||
$deleted_count = 0;
|
||||
|
||||
//if ($messages) {
|
||||
// if ($messages) {
|
||||
// $chunks = array_chunk($messages, $batch_size);
|
||||
// foreach ($chunks as $chunk) {
|
||||
// foreach ($chunk as $message_number) {
|
||||
@@ -50,9 +51,9 @@ $deleted_count = 0;
|
||||
// $deleted_count += count($chunk);
|
||||
// }
|
||||
// echo $deleted_count . ' messages older than specified time have been deleted.';
|
||||
//} else {
|
||||
// } else {
|
||||
// echo 'No messages older than specified time found in mailbox.';
|
||||
//}
|
||||
// }
|
||||
|
||||
if ($messages) {
|
||||
$chunks = array_chunk($messages, $batch_size);
|
||||
@@ -71,7 +72,7 @@ if ($messages) {
|
||||
}
|
||||
imap_expunge($inbox);
|
||||
}
|
||||
echo $deleted_count . ' messages older than 2 hours have been deleted.';
|
||||
echo $deleted_count.' messages older than 2 hours have been deleted.';
|
||||
} else {
|
||||
echo 'No messages found in mailbox.';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user