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.

creating email accounts from ssh

Discussion in 'E-mail Discussions' started by pasqd3, Feb 26, 2011.

  1. pasqd3

    pasqd3 Registered

    Joined:
    Jan 17, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hello

    I have a list like 200 accounts name and passes to create in cpanel, Its on one user (in the same domain). Is it possible to create them from ssh ? Doing it via control panel would be a real pain...
     
  2. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    805
    Likes Received:
    19
    Trophy Points:
    18
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    Well, email accounts are stored in /home/$user/etc/$domain/passwd with an associated shadow file in the same folder. So I assume if you can match the formats and hash the passwords (there are perl scripts that can do that), it should work just fine.

    A while back a cpanel staff member wrote a PHP class to let you access API/API2 functions, so if you're proficient in programming you may be able to use it. I don't recall where it is exactly, but I think this is it:

    XML API PHP class version 1.0 - cPanel Integration
     
  3. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    While the API would be a good way to perform this, there is a script in /scripts/ directory that is /scripts/addpop that has these arguments to create working email accounts:

    Code:
    /scripts/addpop emailuser@domain.com password quota
    Here emailuser is the email username, domain.com is the domain name, password is the email account password, and quota is the size in MB for the email account. You could run a loop through a list of email accounts in a text file to then run the script and have all of these created that way.
     
  4. ryan4021

    ryan4021 Registered

    Joined:
    Mar 8, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    The SSH script worked PERFECTLY for creating an account. Is there a similar script function for removing a pop account? Thanks!
     
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello,

    Such a script does exist. It is the following:

    Code:
    /scripts/delpop emailuser@domain.com
    Simply replace emailuser@domain.com with the email address to remove.

    Thanks!
     
Loading...

Share This Page