This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Auto Deleting The Mails From Trash Folder and Junk
#1
[Solved] Auto Deleting The Mails From Trash Folder and Junk
Step1 : create a file named "deljunk.php"on your server root



Code:
cd
nano deljunk.php

deljunk.php :


PHP Code:
<?php
define 
("DB_HOST""localhost"); // set database host
define ("DB_USER""postfix"); // set database user
define ("DB_PASS","XXXXXXXXXXXXXXXXXXX"); // set database password
define ("DB_NAME","sentora_postfix"); // set database name
$email mysqli_connect(DB_HOSTDB_USERDB_PASSDB_NAME) or die("Couldn't make connection.");
$getMailsDisplay $email->query("SELECT username FROM `mailbox`");
foreach(
$getMailsDisplay as $array){
foreach(
$array as $key=>$value){
echo 
$value."|";
shell_exec("doveadm expunge -u $value mailbox Junk savedbefore 15d");
shell_exec("doveadm expunge -u $value mailbox Trash savedbefore 15d");
}
}
?>


Step2 : Create a cron task to run every nigth


Code:
crontab -e

add at the end:


Code:
30 4 * * * php deljunk.php
Reply
Thanks given by:


Possibly Related Threads...
Thread Author Replies Views Last Post
How to trasnfer mails from one server to another dimnas 1 1 594 02-18-2018, 07:47 AM
Last Post: Me.B
sent out mails going to junk/spam Roma 4 3 499 08-10-2017, 12:57 AM
Last Post: Roma
Outgoing Mails Not working [URGENT] debasis 7 6 905 01-21-2017, 04:40 AM
Last Post: Me.B

Forum Jump:


Users browsing this thread: 1 Guest(s)