From de61a8fa293e41ae9a01044a977f47e64082bb5a Mon Sep 17 00:00:00 2001 From: Synox Date: Fri, 24 Mar 2017 21:38:20 +0100 Subject: [PATCH] :sparcles: added config delete_messages_older_than --- src/backend.php | 10 ++++------ src/config.sample.php | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backend.php b/src/backend.php index d89574e..fb67dd1 100644 --- a/src/backend.php +++ b/src/backend.php @@ -49,8 +49,7 @@ function print_emails($username, $address) { function delete_email($mailid, $address) { global $mailbox; - $email = _load_one_email($mailid, $address); - if ($email !== null) { + if (_load_one_email($mailid, $address) !== null) { $mailbox->deleteMail($mailid); $mailbox->expungeDeletedMails(); header('Content-type: application/json'); @@ -71,8 +70,7 @@ function delete_email($mailid, $address) { function download_email($mailid, $address) { global $mailbox; - $email = _load_one_email($mailid, $address); - if ($email !== null) { + if (_load_one_email($mailid, $address) !== null) { header("Content-Type: message/rfc822; charset=utf-8"); header("Content-Disposition: attachment; filename=\"$address-$mailid.eml\""); @@ -132,9 +130,9 @@ function _clean_username($username) { * deletes messages older than X days. */ function delete_old_messages() { - global $mailbox; + global $mailbox, $config; - $ids = $mailbox->searchMailbox('BEFORE ' . date('d-M-Y', strtotime('30 days ago'))); + $ids = $mailbox->searchMailbox('BEFORE ' . date('d-M-Y', strtotime($config['delete_messages_older_than']))); foreach ($ids as $id) { $mailbox->deleteMail($id); } diff --git a/src/config.sample.php b/src/config.sample.php index 56f018a..9c03143 100644 --- a/src/config.sample.php +++ b/src/config.sample.php @@ -19,3 +19,6 @@ $config['imap']['password'] = "test"; // email domain, usually different from imap hostname: $config['mailHostname'] = "example.com"; + +// When to delete old messages? +$config['delete_messages_older_than'] = '30 days ago'; \ No newline at end of file