added premium promotion, dropmail.php, dropattach.php, minor update of other files

This commit is contained in:
Gitea
2025-05-08 05:46:00 +05:30
parent b24bf3d1f6
commit f8ce844625
10 changed files with 187 additions and 12 deletions

51
dropmail.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
set_time_limit(0);
$newTimezone = 'Europe/London';
date_default_timezone_set($newTimezone);
$imapDB = json_decode(config('app.settings.imap_settings'), true);
// Mailbox credentials
$hostname = '{'.$imapDB['host'].':'.$imapDB['premium_port'].'/ssl}INBOX';
$username = $imapDB['username'];
$password = $imapDB['password'];
// Connect to mailbox
$inbox = imap_open($hostname, $username, $password);
// Check for connection errors
if (!$inbox) {
die('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);
$batch_size = 10;
$deleted_count = 0;
if ($messages) {
$chunks = array_chunk($messages, $batch_size);
foreach ($chunks as $chunk) {
foreach ($chunk as $message_number) {
imap_delete($inbox, $message_number);
}
imap_expunge($inbox);
$deleted_count += count($chunk);
}
echo $deleted_count . ' messages older than specified time have been deleted.';
} else {
echo 'No messages older than specified time found in mailbox.';
}
// Close mailbox connection
imap_close($inbox);
?>