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.

SOLVED Batch mail deleting by date

Discussion in 'E-mail Discussions' started by teknom, Mar 7, 2017.

  1. teknom

    teknom Member

    Joined:
    May 20, 2016
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Turkey
    cPanel Access Level:
    Root Administrator
    hello, i have some mail clients over 50++ on different domains. is it possible to delete older mails on mailboxes by date?
    i want to delete older than 2016 (receive time) mails from all users mailboxes.
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,404
    Likes Received:
    53
    Trophy Points:
    28
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi,

    You can use the find command in the particular directory to search it and remove it completely..

    For example if you want to remove files older than 10 days, use below command:

    # find /path/to/files* -mtime +10 -exec rm {} \;

    You can alter the command as per your requirement to do this..
     
  3. teknom

    teknom Member

    Joined:
    May 20, 2016
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Turkey
    cPanel Access Level:
    Root Administrator
    i search some dirs and got this dir for mails. i guess inbox mails are stored in /home/domainuser*/homedir/mail/domain.com*/mailuser*/cur directory.
    but these files does not have any extension. if i delete these files from this directory, does it cause any error? i mean these mail files indexed anywhere? mysql table or something else?
     
  4. teknom

    teknom Member

    Joined:
    May 20, 2016
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Turkey
    cPanel Access Level:
    Root Administrator
    okay i got this, all mail files name includes my FQDN name and i find and print mails older than 90 days with this command.
    but i tried to add -exec rm {} \ command its not worked. no mails deleted. how can i combine this command with -exec ?

    ohh i forgot the semicolon. thats done thanks
     
    #4 teknom, Mar 8, 2017
    Last edited by a moderator: Mar 9, 2017
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,288
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm happy to see you were able to address the issue. As I understand, you wanted to remove all emails past a certain date, not just the ones in the "Trash" directory, however I do want to note the existence of the following feature in "WHM >> Mailserver Configuration":

    Auto Expunge Trash

    When this option is enabled, the system will remove messages in the Trash and Deleted Messages folders based on the expiration time configured in the option found below it.

    Thank you.
     
  6. teknom

    teknom Member

    Joined:
    May 20, 2016
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Turkey
    cPanel Access Level:
    Root Administrator
    Thanks Michael i already use this feature but some of my clients storage their mails on inbox folder older than 2015. some mailboxes sized over GBs. actually, my problem is lower disk space. and i checked on backup files, the mail folders take up more spaces. therefor i find this solution :) any way for excluding mail folders on backup configuration?
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,288
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page