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 Can i Create Email Automatically 10,000 email

Discussion in 'cPanel Developers' started by HeshamAlassaf, May 6, 2012.

  1. HeshamAlassaf

    HeshamAlassaf Registered

    Joined:
    May 6, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    hello ,

    I want to Create 10,000 email on my web site !?
    how can i do it ?
    with php or anything


    thanks ..
     
  2. charsleysa

    charsleysa Active Member

    Joined:
    Jul 18, 2011
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Palmerston North, New Zealand
    cPanel Access Level:
    Root Administrator
    Well what are your intentions for this? If it is for spam then sorry we cant help you.
    Please expand your explanation of your situation.
     
  3. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    If you do a search on mass email accounts creations cPanel API, you will find several returns. A few of those appear to have the starting basis for how to accomplish this task. I'm not going to presume the reason for doing this in any way, but it will require coding and using the API to load in a list of email addresses, domains and passwords for the creation.
     
  4. HeshamAlassaf

    HeshamAlassaf Registered

    Joined:
    May 6, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    My dear brothers, is meant by e-mail is a communications company, and not for other things, you have a quick way automatically
     
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    If you know how to program, the quick way is to review the API documentation and use an array to create them. Otherwise, you could do the following, but this isn't guaranteed to always work since you aren't using the API (and scripts can change outside the API):

    1. Create a file with all the email addresses, passwords and quotas in it in this format

    Code:
    email1@domain1.com pass1 250
    email2@domain1.com pass2 200
    email3@domain1.com pass3 100
    email1@domain2.com pass4 250
    email2@domain2.com pass5 100
    Here email1@domain1.com is the first email for the first existing domain on an account. The domain must exist, while the email account cannot exist. The pass1 represents the password for that first email account. The 250 represents 250MB for that first account. Revise the values in the file accordingly and call the file /root/newemail for the following script I am about to provide.

    2. Create the script to create the email accounts:

    Code:
    #!/bin/sh
    
    while read x ; do \
        xEMAIL=`echo $x | cut -d' ' -f1`
        xPASS=`echo $x | cut -d' ' -f2`
        xQUOTA=`echo $x | cut -d' ' -f3`
    
        /usr/local/cpanel/scripts/addpop $xEMAIL $xPASS $xQUOTA
    
    done < /root/newemail
    This script could be called /usr/local/cpanel/scripts/createemail or something of that nature. If you do call it that, then make sure you create execute permissions on it:

    Code:
    chmod +x /usr/local/cpanel/scripts/createemail
    3. Run the script in command line:

    Code:
    /usr/local/cpanel/scripts/createemail
    It worked for me following the above steps just fine:

    Code:
    root@host [/usr/local/cpanel/scripts]# ./createemail
    Created tristan24@daniellewallace.com with password pass1 with a quota of 250 MB for user danielle
    Created admin2@endar.org with password pass2 with a quota of 205 MB for user endar
    Created admin3@endar.org with password pass3 with a quota of 200 MB for user endar
    If the domains don't already exist, you'll have to create the domains as they need to exist for this to work. The /usr/local/cpanel/scripts/addpop script that already exists under cPanel can only associate the email addresses properly if the domain is owned by an account.

    You are very welcome!
     
  6. charsleysa

    charsleysa Active Member

    Joined:
    Jul 18, 2011
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Palmerston North, New Zealand
    cPanel Access Level:
    Root Administrator
    You could also try a PHP script being run as root.

    Here is a small snippet of code that would construct the array from a file mention by cPanelTristan:
    Code:
    // Get list of emails
    $email_array = file("/enter/file/path/here", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    
    // Assume the $email_array already contains our array talked about above
    foreach ($email_array as $email)
    {
        // Explode the line to get info
        $email = explode(' ', $email);
        
        // Make sure the info is correct
        if (count($email) < 3)
        {
            echo "ERROR: faulty email line - " . $email[0];
            continue;
        }
        
        // Create the email address
        echo exec('/usr/local/cpanel/scripts/addpop ' . $email[0] . ' ' . $email[1] . ' ' . $email[2]);
    }
    
     
Loading...

Share This Page