Delete automatically unused emails, is it possible? [moved]

freedman

Well-Known Member
Feb 13, 2005
314
5
168
technicolor said:
I'd like to create a php script to delete unused emails for my cpanel account. Anyone help me please?
well. I'm not sure what you mean... how are you wishing to determine what "unused" is

email users are stored in:
/home/USERDIR/etc/DOMAIN/{passwd,shadow}
and there's a folder in /home/USERDIR/etc/DOMAIN/ for some email names

if you're wanting to delete other unused emails, you'll have to be more specific about what you're trying to do in order for anyone to help you.
 

technicolor

Member
Mar 11, 2004
18
0
151
italy
well. I'm not sure what you mean... how are you wishing to determine what "unused" is

email users are stored in:
/home/USERDIR/etc/DOMAIN/{passwd,shadow}
and there's a folder in /home/USERDIR/etc/DOMAIN/ for some email names

if you're wanting to delete other unused emails, you'll have to be more specific about what you're trying to do in order for anyone to help you.
Hi, i propose this question again. I need a php script to delete automatically and dayly unused email account. Unused means that [email protected] was not read from POP3 and webmail from 100 days. Thanks for help and sorry for english
 

freedman

Well-Known Member
Feb 13, 2005
314
5
168
Hi, i propose this question again. I need a php script to delete automatically and dayly unused email account. Unused means that [email protected] was not read from POP3 and webmail from 100 days. Thanks for help and sorry for english
for this solution you would have to sift through the mail logs. You would have to track (daily) which accounts received valid logins from pop or imap (webmail likely uses imap).
then you could know who to delete.. but unless you keep your mail logs for 100 days, you wont be able to do this without storing this historical infomation somewhere.

the maillog for dovecot--I'm not sure if mailman is exactly the same--entries look like this:

MON DAY TIME HOST dovecto: POP3(email_address): ....

so I'd grab those, and store them with their dates.. any that dont have entries within 100 days can be deleted in your case
 

technicolor

Member
Mar 11, 2004
18
0
151
italy
for this solution you would have to sift through the mail logs. You would have to track (daily) which accounts received valid logins from pop or imap (webmail likely uses imap).
then you could know who to delete.. but unless you keep your mail logs for 100 days, you wont be able to do this without storing this historical infomation somewhere.

the maillog for dovecot--I'm not sure if mailman is exactly the same--entries look like this:

MON DAY TIME HOST dovecto: POP3(email_address): ....

so I'd grab those, and store them with their dates.. any that dont have entries within 100 days can be deleted in your case
Where can i read mail logs login? Every day i can read this file and update a database where i can update last login for every email account. Do you think is this a solution for my problem?
 

freedman

Well-Known Member
Feb 13, 2005
314
5
168
Where can i read mail logs login? Every day i can read this file and update a database where i can update last login for every email account. Do you think is this a solution for my problem?
/var/log/maillog is probably what you want.

and yes, read it every day.. grab the info you need and put it someplace.