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!

Mass Email Account Removal

Discussion in 'E-mail Discussion' started by keithc, Jan 7, 2008.

  1. keithc

    keithc Member

    Joined:
    Jun 5, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    151
    Hi,

    Was just wondering if anyone knows of a way to perform a mass removal of a bunch of email accounts. Over the years, the company I work for has given out a lot of free email addresses. Now, we are cleaning a lot of these up. I have about 300 email accounts I need to delete.

    Is there a way on the command-line to remove these accounts or another way in Cpanel besides deleting each account one at a time?

    I was thinking that just removing the email accounts from the domain's ./etc/passwd file might work since all of the accounts are listed there?

    Here is my Cpanel information

    WHM 11.11.0 cPanel 11.16.0-C18546
    CENTOS Enterprise 4.6 x86_64 on standard - WHM X v3.1.0

    Thanks,

    Keith
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    22
    Trophy Points:
    463
    Location:
    Go on, have a guess
    POP3 accounts aren't listed in /etc/passwd, they're stored within account/domain specific passwd/shadow files within /home/account/etc/...

    You can do this if you write a script that calls:

    /usr/local/cpanel/cpanel-email 'delpop' '<account>' '0' '<domain>'

    Substituting <account> and <domain> as appropriate. That said, this method wouldn't be endorsed by cPanel (you should really use the UI).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. keithc

    keithc Member

    Joined:
    Jun 5, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    151
    Thanks Chirpy.

    I tried to delete an account using this method but I may be doing it wrong.

    Let's say I have an account called test@testing.com

    Would I run /usr/local/cpanel/cpanel-email 'delpop' 'test' '0' 'testing.com'

    Thanks,

    Keith
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    22
    Trophy Points:
    463
    Location:
    Go on, have a guess
    I missed a bit out - you have to run that under the cPanel account. So, for a POP account of test10@webumake.net which belongs to cPanel account webumake, you would use:

    su --login -s /bin/bash webumake -c "/usr/local/cpanel/cpanel-email 'delpop' 'test10' '0' 'webumake.net'"
     
    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