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.

How to empty default email account

Discussion in 'E-mail Discussions' started by willdeb, Jun 20, 2013.

  1. willdeb

    willdeb Member

    Joined:
    Jul 19, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I have several default email accounts on my server that grew quite large before I learned how to set them to "fail". They are much too large to clean out using webmail.

    How can I clean out these accounts to free space on the server?

    Sorry if this has been discussed before. I searched but could not find.

    Thanks for your help.
     
  2. kdean

    kdean Well-Known Member

    Joined:
    Oct 19, 2012
    Messages:
    262
    Likes Received:
    12
    Trophy Points:
    18
    Location:
    Orlando, FL
    cPanel Access Level:
    Root Administrator
    From the shell, you can go to:

    /home/cpanel_user/mail/

    … and delete the contents of the cur and new folders at the top level.
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,666
    Likes Received:
    646
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Yes, emails for the default account are stored under the appropriate maildir directory (e.g. cur, new) in "/home/username/mail".

    Thank you.
     
  4. willdeb

    willdeb Member

    Joined:
    Jul 19, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thank you both. Could you give me an example of the commands needed/

    In one case the user is fishhoo and the default mailbox is using over 520 mb.

    Thanks again.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,666
    Likes Received:
    646
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You can utilize the "rm" command to remove files from a directory. Here is an example of how to remove all files from a directory:

    Code:
    # rm -fv /home/username/mail/cur/*
    Remember to use caution when deleting files with the "rm" command as you want to avoid deleting the incorrect file or directory.

    Thank you.
     
  6. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Or, go to the file, lets say the "inbox" and run:
    Code:
    echo -n > inbox
    Above command will empty file but not delete it. Will also preserve permissions etc.
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,666
    Likes Received:
    646
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Emptying the individual email files is not a good idea if the intention is to delete all of the emails. This would leave the user with several empty emails in their inbox.

    Thank you.
     
  8. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    True, but for someone not used to using the command line its a lot safer than using rm -f command.
     
  9. willdeb

    willdeb Member

    Joined:
    Jul 19, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Gentlemen,

    Sorry, I had to go to a real job. Please understand that I want to empty ONLY the default email accounts. Some of my clients have legitimate email accounts that I do not want to disturb.

    Will the above suggestions accomplish that?

    Again, thanks for your help.
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,666
    Likes Received:
    646
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Yes, the email data for the default email account is mostly stored in the following two directories:

    /home/username/mail/cur
    /home/username/mail/new

    The email data for individual email accounts is stored in the maildir directories within:

    /home/username/mail/domain.com/email-account-name

    Thank you.
     
  11. willdeb

    willdeb Member

    Joined:
    Jul 19, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I tried
    root@vs1 [~]# rm -fv /home/fishhoo/mail/cur/*

    That may have worked, but whem I tried

    root@vs1 [~]# rm -fv /home/fishhoo/mail/new/*

    I received the message

    -bash: /bin/rm: Argument list too long

    I assume that did not work.
     
  12. willdeb

    willdeb Member

    Joined:
    Jul 19, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
  13. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,666
    Likes Received:
    646
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You could try a command such as:

    Code:
    find /home/username/mail/new -name "123*" -exec rm -fv {} \;
    Replace the "123*" entry with a prefix of what your files within this directory start with. This is a safeguard so you do not use the command incorrectly and delete files you are not supposed to. Ensure you are careful with the directory that you enter in this command because we do not generally recommend mass deletion of files.

    Thank you.
     
  14. willdeb

    willdeb Member

    Joined:
    Jul 19, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Unfortunately I have no idea what that that prefix might be. I think I will show this thread to my tech support people so they can help.
     
  15. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,666
    Likes Received:
    646
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You could view a list of the files in the directory with a command such as "ls" to see what the file names start with specifically. However, yes, it's a good idea to consult with a qualified system administrator if you are not experienced on the command line. This is especially true when deleting files.

    Thank you.
     
  16. ThinIce

    ThinIce Well-Known Member

    Joined:
    Apr 27, 2006
    Messages:
    346
    Likes Received:
    7
    Trophy Points:
    18
    Location:
    Disillusioned in England
    cPanel Access Level:
    Root Administrator
  17. Leonardo Gomes

    Joined:
    Jun 10, 2005
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    In the past to resolve this kind of issue, i created a script to clean all mailqueue, with some adjustment you can use the same.

    #!/usr/bin/perl

    my $date = `date`;
    chomp $date;

    open (LOG, ">>/root/scripts/resetmailqueue.log") || die "Falha ao abrir arquivo ::$!";

    print LOG "$date - Apagando fila de mensagens do Exim.......";

    if(!system("rm -d -f /var/spool/exim/input/*/*")){
    print LOG "[Ok]\n";
    }else{
    print LOG"[Erro]\n";
    }
    close (LOG);
     
  18. Data 1

    Data 1 Well-Known Member

    Joined:
    May 25, 2008
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Columbus Ohio
    cPanel Access Level:
    DataCenter Provider
    Old thread I know, and long time no post sorry.

    Been moving some very old accounts to my newest array of servers, evidently these accounts were configured in the beginning (not by me) to save everything in the default e-mail address. The one I am working on is 18G.

    I too get the bash: /bin/rm: Argument list too long message

    ls and dir just set there wondering how they are going to display 18G of files then starts rattling off numbers.
    There are several prefixes, all just numbers. There are a lot of each prefix so the command where you put in the prefix could never delete them all.

    I probably have about 40 accounts in this condition, ones I assumed from another host who went out of business.

    This isn't critical but as root you think you would be able to execute one command and wipe everything out or with google you would be able to find the magic command that would clear the entire directory.

    Any new thoughts on this?
    Thanks-
     
  19. Data 1

    Data 1 Well-Known Member

    Joined:
    May 25, 2008
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Columbus Ohio
    cPanel Access Level:
    DataCenter Provider
    And experimenting on a home server moments later I find the magic.

    Make sure you are IN the directory you want to delete.

    find . -type f -print -delete

    This will show them to you as it zaps them and takes A LOT LESS TIME than find . -type f -exec rm -v {} \;

    In short evidently find has rm built in as -delete

    I accept no responsibility for people destroying their entire servers executing commands from my post, please shell responsibly :)
     
    #19 Data 1, Dec 1, 2013
    Last edited: Dec 1, 2013
  20. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,446
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    You might also ask them to update your cPanel for you. It's severely out of date and unsupported.
     
Loading...

Share This Page