How To Mass Create Email Addresses In cPanel

Use this php script to generate the iMacros code. It just loops over your list and places the username and password into the right spots:

<?php
$text=”jamese,sup3rs3cr3t
maxp,sh0p3rs7ar
jeremys,madsk1llz”;
$text = explode(”\n”,$text);
echo “VERSION BUILD=6000918 RECORDER=FX\n”;
foreach($text as $v) {
list($name,$pass) = explode(’,',trim($v));
echo “TAB T=1
URL GOTO=http://www.mysite.com:2082/frontend/x3/mail/pops.html
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:mainform ATTR=ID:email CONTENT=$name
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:mainform ATTR=ID:password CONTENT=$pass
TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:mainform ATTR=ID:passagain CONTENT=$pass
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:mainform ATTR=ID:quota CONTENT=100
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:mainform ATTR=VALUE:Create
TAG POS=1 TYPE=A ATTR=TXT:Go<SP>Back\n”;
}
?>

The only thing you need to change in the script is the line that reads:
URL GOTO=http://www.mysite.com:2082/frontend/x3/mail/pops.html

Basically you need to login to cpanel, click on your Add/Remove Email Accounts or Email Accounts (it varies depending on your theme) to get that URL. Just to be totally clear, this is the page where you add email addresses. The url of that page is what needs to go on that line.

I run this code from my computer with WAMP, but you could run it from any server that supports PHP. After you run the script, just copy the results.

Read on to figure out how to make this work with iMacros…

Pages: 1 2 3

if you liked this post :)

Category: Programming | 1,230 views | Posted: March 6th 2008 01:45 am

Related Posts

3 Comments »

MyAvatars 0.2

Comment by Tim
on 06 Mar 2008 at 2:59 am #

Nice post!

I think you can do all this without even using PHP. iMacros can read from CSV files directly. So in your macro just use

CMDLINE !DATASOURCE Address.csv
‘Number of columns in the CSV file. This must be accurate!
SET !DATASOURCE_COLUMNS 1
‘Start at line 2 to skip the header in the file
SET !LOOP 2

And then use {{!COL1}} for your emails:
TAG POS=1 TYPE=… CONTENT={{!COL1}}

I got this idea from http://wiki.imacros.net/Demo-Loop-Csv-2-Web

 
MyAvatars 0.2

Comment by David Grega
on 06 Mar 2008 at 11:52 am # Subscribed to comments via email

You can avoid the possibility of the code being obsoleted by a new GUI by accessing the APIs directly. You can use our XML-API to call the appropriate API1/API2 functions that handle the actual creation of mail accounts. If you have root access, all you have to do is analyze the code of the X3 theme to see what APIs it calls and use those calls yourself.

The X3 theme is located at /usr/local/cpanel/base/frontend/x3

The paths for individual screens is fairly simple as it is merely a series of special web pages. For example, frontend/x3/mail/pops.html would be located at /usr/local/cpanel/base/frontend/x3/mail/pops.html - though all that particular page does is pass parameters to another page to be processed. The code is fairly simple and easy to sort though.

We are currently working on comprehensive API documentation so you wont need to look at the X3 source code to determine which API calls you need to use. However, you can find our current documentation on our website at:

http://www.cPanel.net/plugins/devel

 
MyAvatars 0.2

Comment by James Ehly
on 06 Mar 2008 at 3:36 pm #

Awesome comments Guys! Thanks for your response and for the ideas!

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

« Things that Suck About MODx CMS | For The Love of God, Rotate Your Logs »