Questions about the new email API

MagnuM

Verified User
Joined
Oct 24, 2003
Messages
122
Location
Romania
Thanks for the CMD_CHANGE_EMAIL_PASSWORD. It was realy necessary. If for a successful password change we have a redirect, I am asking how can I redirect a user somewhere else if the old password is wrong, or the confirmation of the new password is not good?

And the CMD_API_POP, I don't know how to use it.
Is this one working only if the users are logged into DA?

I try
Code:
http://mydomain.com:2222/CMD_API_POP?action=list&domain=mydomain.com
and it gives me the login form.
 
Last edited:
i.e., for CMD_API_POP:
PHP:
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;

$sock->connect('yoursite.com',2222);
$sock->set_login('admin','password');

$sock->query('/CMD_API_POP','action=list&domain=mydomain.com');
$array_result = $sock->fetch_parsed_body();

print_r($array_result);

?>
 
Thanks man, you've been more than helpful, by sharing your knowledge with us (all people from this forum).

So I just check http://www.directadmin.com/api.html, but there are no explanations about the new available email API's.

Here are some new questions:
1. Do I need your class for using of CMD_CHANGE_EMAIL_PASSWORD? Because I think, it doesn't require to login.
2. How do I handle the possible error types when change an email password (I need only one good ideea).
3. The API used to create email accounts (CMD_API_POP) doesn't specify the quota for the email box, only the email user and password. Is there a default qouta used by DirectAdmin when create an virtual email box?

Thanks again for everything.
 
Last edited:
MagnuM said:
1. Do I need your class for using of CMD_CHANGE_EMAIL_PASSWORD? Because I think, it doesn't require to login.
Ah, I see. Didn't realize that. Pretty cool.

MagnuM said:
2. How do I handle the possible error types when change an email password (I need only one good ideea).
Well, unless you plan on simply forwarding people to http://yorurhostname:2222/CMD_CHANGE_EMAIL_PASSWORD, you will need to make use of the class. DA will include error=1 in its result if there is an error.

MagnuM said:
3. The API used to create email accounts (CMD_API_POP) doesn't specify the quota for the email box, only the email user and password. Is there a default qouta used by DirectAdmin when create an virtual email box?
Not sure. John will have to tell us that (...and explain why there isn't an option in the API to change it). :)

I'll reply with some code in a few minutes.
 
For CMD_CHANGE_EMAIL_PASSWORD, this should work:
PHP:
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;

$sock->connect('yoursite.com',2222);

$sock->query('/CMD_CHANGE_EMAIL_PASSWORD',"api=yes&email={the_email_address}&oldpassword={old_password}&password1={new_password}&password2={new_password_confirm}");
$array_result = $sock->fetch_parsed_body();

if ($array_result['error'])
{
	die("An error has occured: {$array_result['text']}");
}

echo "Password of {the_email_address} has been changed. Here's what DA said: {$array_result['text']}";

?>

This is untested but should work.
 
Thanks, I want to write myself the same thing, but I thought that CMD_CHANGE_EMAIL_PASSWORD works only with POST. This is where I remain blocked, because I don't know how to use your class with the POST protocol.

Thanks anyway.
 
MagnuM said:
Thanks, I want to write myself the same thing, but I thought that CMD_CHANGE_EMAIL_PASSWORD works only with POST. This is where I remain blocked, because I don't know how to use your class with the POST protocol.

Thanks anyway.
It works via GET, but if you want POST, after
$sock->connect('yoursite.com',2222);
add
PHP:
$sock->set_method('POST');
 
Hello,

Just to clarify:

CMD_CHANGE_EMAIL_PASSWORD

does not require a DirectAdmin login/password. It works externally from all of the sessions and doesn't *need* to be used with the communication class. It does support both GET and POST but if neither are given, it will show the html page for users to change their passwords. If either GET or POST (or both) are provided, it will assume you're trying to change the email password and will do all of the required form checks. If api=yes is passed, the results will be in API form. If api isn't provided, then the results will be in human readable form (used if you are doing it via plain html and a web browser. api=yes is only needed for scripts running that command.



CMD_API_POP

DOES require the DirectAdmin login/password and sesssions etc.. Will work with GET or POST. Quota is supported in that command, I just forgot to add it ("quota") to the versions update. I also didn't get around to adding it to the api.html yet, so I'll try and get on that soon. Errors are straight forward.. if there isn an error, it will return error=1 with "text" and "details" about the errror.

John
 
I know it's an old thread but I have a question regarding CMD_CHANGE_EMAIL_PASSWORD.

Is there any way to change a pop account password without oldpassword?
I would like to log in as usually using DA login / pass and change any of my pop accounts password.

Any help?
Thanks!
 
Oh - haven't noticed that :)
Thanks a lot!

(You should probably take all of the api commands and put it in one refference / faq or something that is easier to browse)
 
Back
Top