creating email accounts from ssh

pasqd3

Registered
Jan 17, 2011
2
0
51
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...
 

vanessa

Well-Known Member
PartnerNOC
Sep 26, 2006
833
28
178
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
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
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 [email protected] 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.
 

ryan4021

Registered
Mar 8, 2012
1
0
51
cPanel Access Level
Website Owner
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 [email protected] 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.
The SSH script worked PERFECTLY for creating an account. Is there a similar script function for removing a pop account? Thanks!
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator