The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Auto Delete Emails in Multiple Email Accounts at once

Discussion in 'cPanel Developers' started by stombaugh, Jan 22, 2010.

  1. stombaugh

    stombaugh Registered

    Joined:
    Jan 22, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I need to be able to delete any and all emails from multiple email accounts at once. Is this possible to have maybe a Cron job run this every week or something like that? I have the passwords to all 1500+ email accounts on my server and I just need to be able to delete all contents of email accounts every week or so.
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Well, there is no way to do this via the APIs unless you were to do something like remove & readd the accounts once a week. The easiest way to do this would be by manually removing files inside of the users maildir at:

    /home/$username/mail/.$email_username/cur/* - READ inbox message
    /home/$username/mail/.$email_username/new/* - UNREAD inbox messages
    /home/$username/mail/.$email_username/*/new/* - UNREAD mail folder messages
    /home/$username/mail/.$email_username/*/cur/* - READ mail folder messages

    After this has been done for all accounts, /scripts/generate_maildirsize should probably be run to ensure that correct mailbox usage is correct accounted for.
     
  3. stombaugh

    stombaugh Registered

    Joined:
    Jan 22, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I found a cron job to do it for me:

    find /home/*/mail/*/*/*/* -type f -mtime +1 | xargs rm -rf

    It works and it deletes everything.
     
Loading...

Share This Page