Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Delete old emails

Discussion in 'E-mail Discussion' started by jnorris235, May 19, 2017.

  1. jnorris235

    jnorris235 Registered

    Joined:
    May 19, 2017
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    England
    cPanel Access Level:
    Reseller Owner
    In order to delete emails over 6 months old, that are sat in an INBOX (and NOT in any other folders created by client) would somebody be kind enough to offer a php script?
    I understand I can put this script in my public_html directory and call for it to run by a CRON command such as > /home/cPaneluser/public_html/yourscript.php
    It would seem the easiest way for me as I can understand php, but not bash scripts or other suggestions I have read.

    I apologise for being out of my depth reading other replies - but it appears also to me that they would delete ALL emails over 6 months old (for example) and not just those in a specified mailbox. Your patience appreciated!
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,861
    Likes Received:
    89
    Trophy Points:
    78
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi,

    If you want to perform this deletion activity through PHP, then you may end up enabling some PHP vulnerable function that is required to actually execute the removal command, in an attempt you may get in trouble with opening your server for attacks. Please be careful...

    A bash script would be perfect way for you to do this..
    Hint: You can remove the mails from the "cur" folder that has the new and current emails..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. jnorris235

    jnorris235 Registered

    Joined:
    May 19, 2017
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    England
    cPanel Access Level:
    Reseller Owner
    >> What do I actually do with a bash script - can it made to run automatically (via a cron job perhaps?)
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,339
    Likes Received:
    402
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Not sure why you'd need a script for this when it can be done from in your cPanel easy enough.
    cPanel > Email > Email Accounts > choose an email account you'd like to clean up by clicking the More menu to the right of the email account listed here, then select Manage Disk Usage. Click Manage to the right for some options.

    Will this fit your needs?

    mngdskusgsttngs.jpg
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. jnorris235

    jnorris235 Registered

    Joined:
    May 19, 2017
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    England
    cPanel Access Level:
    Reseller Owner
    That is absolutely perfect, thought I'd investigated everything on cPanel, many google searches, then got bogged down with similar threads using more esoteric stuff. Very grateful for your time!
     
    Infopro likes this.
  6. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,339
    Likes Received:
    402
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Happy to help. :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. vanessa9909

    vanessa9909 Registered

    Joined:
    Sep 12, 2017
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    brazil
    cPanel Access Level:
    Website Owner
    Hello
    I would like to know which command I can use to delete messages that are 6 months or older.
    And not from 1 year or more.
     
  8. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,749
    Likes Received:
    1,884
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    You can use the same option in cPanel:

    Email Disk Usage - Version 68 Documentation - cPanel Documentation

    Note the following under the "Remove Messages" section:

    EX:

    Code:
    savedbefore 26weeks
    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. birken

    birken Member

    Joined:
    Oct 28, 2013
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    i am using paper_lantern theme in cpanel and cant find any where to delete email form disk where is it please?
     
  10. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,749
    Likes Received:
    1,884
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    As a reseller, you will need to check with your hosting provider to verify the Email Disk Usage feature is enabled and available for use. It's documented at:

    Email Disk Usage - Version 68 Documentation - cPanel Documentation

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice