:sparcles: added config delete_messages_older_than

This commit is contained in:
Synox 2017-03-24 21:38:20 +01:00
parent 18329f8c78
commit de61a8fa29
2 changed files with 7 additions and 6 deletions

View file

@ -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);
}

View file

@ -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';