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 Delete old emails

Discussion in 'E-mail Discussions' 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,399
    Likes Received:
    52
    Trophy Points:
    28
    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..
     
  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:
    15,618
    Likes Received:
    296
    Trophy Points:
    433
    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
     
  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:
    15,618
    Likes Received:
    296
    Trophy Points:
    433
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Happy to help. :)
     
Loading...

Share This Page