PDA

View Full Version : Problem with add new email account to the DA



M.a.T.a.N
03-25-2011, 04:05 AM
Hellow, at last time I start to be involved with API in DA.
I try to find a php script that add a new email account to my DA.
Anyway I search anywhere from anywhere, and that what i found.

First, I have a file that called that name httpsocket.php, that the file http://files.directadmin.com/services/all/httpsocket/httpsocket.php

I have second file that just called the above file (httpsocket.php), and this is the source:

<?

$server_ip="myipaddress";
$server_login="myusername";
$server_pass="mypasswd";
$server_ssl="N";


$username=$_POST['username'];
$domain=$_POST['domain'];
$email=$_POST['email'];
$pass=$_POST['pass'];
$package=$_POST['package'];


if (isset($_POST['action']) && $_POST['action'] == "add")
{

echo "Creating user $username on server $server_ip.... <br>\n";
include 'httpsocket.php';
$sock = new HTTPSocket;
if ($server_ssl == 'Y')
{
$sock->connect("ssl://".$server_ip, 2222);
}
else
{
$sock->connect($server_ip, 2222);
}

$sock->set_login($server_login,$server_pass);

$sock->query('/CMD_API_POP',
array(
'action' => 'create',
'domain' => $domain,
'user' => $username,
'passwd' => $pass,
'quota' => $package
));

$result = $sock->fetch_parsed_body();

if ($result['error'] != "0")
{
echo "<b>Error Creating user $username on server $server_ip:<br>\n";
echo $result['text']."<br>\n";
echo $result['details']."<br></b>\n";
}
else
{
echo "User $username created on server $server_ip<br>\n";
}

exit;
}

?>


<form action="?" method="POST">
<input type=hidden name=action value="add">
Username: <input type=text name=username><br>
Domain:<input type=text name=domain><br>
Pass: <input type=password name=pass><br>
Packge: <input type=text name=package><br>
<input type="submit" name="submit" value="send" />
</form>

Anyway I try to do anything, like give "777" arttibute permission, change some text in the script and search in any forum and in google.
Of courseג that I set the real parameters in the variables that need the detail.

I really need a simple sample script that add a new email account.
Thank you very much!

zEitEr
03-25-2011, 11:09 AM
And what error do you get when using the script, you've posted? It seems to be a working solution.

M.a.T.a.N
03-26-2011, 12:17 PM
its dont give me a problem, its just dont give me any result.
I run this script couple times and its dont open me email account.
a
i thougt that script should open a new email account.

zEitEr
03-26-2011, 12:25 PM
Add


var_dump($result);

after


$result = $sock->fetch_parsed_body();

and post here results.

M.a.T.a.N
03-26-2011, 03:56 PM
It is dont change anything, its just write "Creating user here comes my user on server here comes my domain...." like before.

there is no result.
Please I need any script that work and could open me a new email account!

Thank's!

zEitEr
03-27-2011, 12:53 AM
1. Re-name the script, content of which you've posted above, from httpsocket.php into pop_create.php (or anything you want).

2. Download http://files.directadmin.com/services/all/httpsocket/httpsocket.php into the directory with pop_create.php.

3. Trigger the script pop_create.php from a browser.


Please, update us with results.

M.a.T.a.N
03-27-2011, 01:20 AM
Soory, I dont understand.
do I need to change the file "httpsocket.php" to "pop_create.php"?
or the other file (index.php) to "pop_create.php"?

and after I downloaded the file you give me, what name I called him?

if I try to get from browesr to file "pop_create.php" and the "pop_create.php" its the "httpsocket.php" file, I get this error.


Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request bestempemail.com
Error 500.

But I dont think its what you want me to do...

zEitEr
03-27-2011, 02:51 AM
In your first Post#1 (http://www.directadmin.com/forum/showpost.php?p=199940&postcount=1), you wrote


I have second file that just called the above file (httpsocket.php), and this is the source:

and below comes its content.

Is it a mistake? Or the code, you've posted there in the Post#1, is the source of the file called httpsocket.php?

If the code is in the file with name httpsocket.php — that's the problem. So you need to rename it and get original httpsocket.php.

M.a.T.a.N
03-27-2011, 03:22 AM
No, the file that I wrote his code here called name "index.php",
and I have second file, the same file you give me in link called name "httpsocket.php".

Anyway, I dont have 2 files with thw same name if its what you thougt, so it is not the problem :(

zEitEr
03-27-2011, 03:56 AM
1. Ensure you've got correct and valid data in here:


$server_ip="myipaddress";
$server_login="myusername";
$server_pass="mypasswd";
$server_ssl="N";

If everything is good here, then

2. Change


$result = $sock->fetch_parsed_body();

with


var_dump($sock);
$result = $sock->fetch_parsed_body();
var_dump($result);



var_dump() would show some debugging information. Without that I'm out of ideas.

M.a.T.a.N
03-28-2011, 11:04 AM
nothing change :(
thank you anyway!!

zEitEr
03-28-2011, 11:43 AM
That would not make the code working. It's a way to learn some more information, so called debugging info. Why don't you post here the output? Without that, I won't help you.

M.a.T.a.N
03-28-2011, 11:49 AM
like I say, nothing change, I still dont see any result =/

But... I got a new error, this error -
http://img14.imageshack.us/img14/6159/98564220.png (http://img14.imageshack.us/i/98564220.png/)

Uploaded with ImageShack.us (http://imageshack.us)

what this is say's?

zEitEr
03-28-2011, 11:59 AM
About error 500 check with apache error log for that domain.

About the first issue, something is really messed up. So, without FTP access, there is nothing I can do for you. Send me a PM if you need more help.

M.a.T.a.N
03-28-2011, 12:13 PM
ohhh Yea~!!!
its just got work, I just needed to define it with ssl !

thank you for your support!!