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.

Importing email accounts in mass?

Discussion in 'E-mail Discussions' started by shaniac, Aug 17, 2004.

  1. shaniac

    shaniac Registered

    Joined:
    Jun 8, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Is there a way to import new email accounts into cPanel, in mass? I have about 2000 email accounts, and entering them by hand is not an option. Thanks in advance.
    -Shane
     
  2. gratisites

    gratisites Registered

    Joined:
    Jan 14, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    I'm looking for the exact same feature. We are currently in the process of designing and maintaining a school website. They have about 500 students, and each student is required to have an email address. We also need to be able to mass delete at the end of each school year. We have been looking at Hive Mail but are unsure of the database structure. Anyways any help would be greatly appreciated. Sorry for hijacking your thread.

    Chris
     
  3. elleryjh

    elleryjh Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    479
    Likes Received:
    0
    Trophy Points:
    16
    If you're using cpanel/exim to manage the accounts, a php script along the line of this should do the trick... to delete the accounts, you would replace doaddpop with dodelpop

    fopen wrappers would have to be enabled because of the file() calling a url.

    This has not been tested. PM me if you need me to implement this for your server.

    PHP:
    <?
    $cpanel_username "accountname";
    $cpanel_password "mypass123";
    $cpanel_theme "x";
    $cpanel_url "http://$cpanel_username:$cpanel_password@$cpanel_domain/frontend/$cpanel_theme/mail/doaddpop.html";

    $email_domain "thisschool.com"
    $email_quota 10// quota in MB

    // associative array: keys are email addresses, values are passwords
    $emails = array("john.smith"=>"1234""jane.smith" => "abcd");

    foreach(
    $emails as $email_address => $email_pass){
    $url =  "$cpanel_url?email=$email_address&domain=$email_domain&password=$email_pass&quota=$email_quota";
    if(
    file($url))
      echo 
    "$url      <br>\n";
    else
      echo 
    "ERROR : $url      <br>\n";
    }
    ?>
     
  4. cmdln

    cmdln Active Member

    Joined:
    Mar 17, 2007
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    supposedly /usr/local/cpanel/cpanel-email can interface to creating or deleting email addresses .... I have yet to find a help file or anything associated. I want to script the creation of email accounts and forwards as well as removal.

    Does anyone know anything about /usr/local/cpanel/cpanel-email ?
     
  5. SoftDux

    SoftDux Well-Known Member

    Joined:
    May 27, 2006
    Messages:
    983
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Johannesburg, South Africa
    cPanel Access Level:
    Root Administrator
    I know this is an old post, but does anyone know if it works? I need to setup a few hundred email addresses, which I have in an excel spreadsheet with the passwords. Any help would be appreciated. Thank you
     
  6. shaun

    shaun Well-Known Member

    Joined:
    Nov 9, 2001
    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    San Clemente, Ca
    /scripts/addpop <email> <pass>

    I think that still works, i have not tested it so give it a try first... if it works it should be very easy for you to take a CSV file and loop it into that script.
     
  7. ackava

    ackava Registered

    Joined:
    Feb 8, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Well how do you call this in PHP? I tried sudo and so many options, it gives unknown error in php, and then I tried also writing perl script but looks like cpanel's custom tag does not let Text::CSV load.

    Php API is not very useful because it requires "x" theme also everything has been upgraded up to x3 and we cant use old theme and moreover even basic authentication is not supported so php xml api is not working.

    /scripts/addpop is right way but only if someone can show in php how to exactly use it.
     
  8. shaun

    shaun Well-Known Member

    Joined:
    Nov 9, 2001
    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    San Clemente, Ca
    system("/scripts/addpop arg1 arg2 arg3");

    php will need to be running as the user root.
     
Loading...

Share This Page