deleting email older than 30 days

david510

Well-Known Member
Aug 22, 2004
473
0
166
Hello,

How can we set up cron in cpanel that will delete mail from the inbox that is older than 30 days? Or can we setup this option in any of the webmail or outlook any ideas?? Or can we write any php script for this to delete mail from a specific inbox and set this script as a cron to run once in every month like that ?? any ideas of this??

Regards,
David
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,466
31
473
Go on, have a guess
There's always the Aging option that cPanel have added available within cPanel > Mail > Manager Accounts > Aging:
Mail aging is the process in which e-mails will be removed from the server automatically, upon successful log out of a pop3 session. This deletion will only occur if the messages are older then a specified amount of days.
Other than that cludge, I'm not aware of a solution to do this nicely. Unfortunately, too many people leave mail on the server in POP3 accounts, when the protocol was never designed with that in mind. It's meant to be a temporary store that the user retrieves in its entirety and then deletes once received. So, it really is the users responsibility to delete their email after they have received it. That said, I'm not aware of any scripts that do what you're looking for, but they may be out there.
 

maverick23

Well-Known Member
Feb 23, 2005
92
0
156
cPanel Access Level
DataCenter Provider
chirpy said:
There's always the Aging option that cPanel have added available within cPanel > Mail > Manager Accounts > Aging:


Other than that cludge, I'm not aware of a solution to do this nicely. Unfortunately, too many people leave mail on the server in POP3 accounts, when the protocol was never designed with that in mind. It's meant to be a temporary store that the user retrieves in its entirety and then deletes once received. So, it really is the users responsibility to delete their email after they have received it. That said, I'm not aware of any scripts that do what you're looking for, but they may be out there.

does it even works when we check the mail through webmail?
 

tloffman

Registered
Feb 27, 2006
1
0
151
Aging not working

Aging not working for me either. I have several email accounts set up and mail is being forwarded from the various addresses to my primary address. When I log in I am able to get all of my forwarded mail OK and then my email client (Eudora) deletes from server. However, mail is NOT deleted from the accounts that forwarded the mail to my primary account. So, I set aging to 1 day. However, it NEVER works. When I go back into my accounts the old email is always on the server. After reading the various posts here and working with aging myself my conclusion is that it just isn't working - so it's a bug in the software. My hosting company can't figure it out either. In the .pdf doc file for cPanel aging isn't even mentioned.
Tom Loffman
 

kernow

Well-Known Member
Jul 23, 2004
1,018
55
178
cPanel Access Level
Root Administrator
I don't know how do do this for all inboxes but for just one inbox, you could set up a cron to run every x days with the command something like:
Code:
cd /home/username/mail | echo -n > inbox
This would delete the contents of the inbox file without deleting the actual inbox !!!
 

truehustercom

Member
Aug 27, 2004
8
0
151
seems that would be a bad idea. what if there is mail unread and the cron is ran and your important data is deleted.
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,466
31
473
Go on, have a guess
Indeed, that would be a terrible idea - you would almost definitely lose email. The best solution is really to educate users in how email works. That they should use POP3 if they want to retrieve email immediately and to not use their email clients option to leave email on the server. OR to use IMAP if they want to leave email on the server. Email and account quotas are there to prevent users doing stupid things like leaving email on the server that they should be retrieving locally.