Add mail users using php?

Snarf

Active Member
Mar 29, 2002
26
0
301
yep that worked :)

now I just need to add some code to make it redirect to another page after adding the email account maybe some code to store there name etc... into a mysql db :)

unless you have already done that ? :)
 

moronhead

Well-Known Member
Aug 12, 2001
706
0
316
OK, it was easy to adjust Jim's script to have a user change his mailbox password and quota remotely without logging on to Cpanel.

Simply take the same script that creates the email account and change the line that starts with $in to (all on one line):

$in = &GET /frontend/USER_THEME/mail/dopasswdpop.html?email=$email&domain=$domain&password=$password1&a=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n&;

Make sure your form's input names match the email, password and quota variables on this line.

Replace the USER_THEME with bluelagoon, default, iconic or whatever the theme for the account is and leave all the rest in the script as is.
 

moronhead

Well-Known Member
Aug 12, 2001
706
0
316
& wouldn't that let anyone be able to change anyone's password though ?

Yes it would. So we need to build some kind of protection. Perhaps a secret word could be confirmed by the user and matched against a MySQL table before going through the cpanel step.
 

Snarf

Active Member
Mar 29, 2002
26
0
301
... I wouldn't know where to start bro.

I am actually working on the signup to store user infomation into an mySQL db when they signup.

as far as checking to see if certain infomation is correct so they can change there pw ...not sure
 

Snarf

Active Member
Mar 29, 2002
26
0
301
oh yeah and if you want it to redirect to another page after making the account:

right after

fputs($socket,$in);
fclose( $socket );

put :

header(&Location: index.php&); /* Redirect browser */
exit; /* Make sure that code below does
not get executed when we redirect. */

make the index.php file whereever you want to redirect too.
 

Snarf

Active Member
Mar 29, 2002
26
0
301
I actually have adapted getting user info and storing it in a database like name address and stuff but it is used with vBulletin forum software.

Now the last step I need to add to it would be something to check whatever encrytion the pw has maybe md5 ?

to another password to enable the user to beable to change the pw.

let me know if you guys have any ideas
 

Snarf

Active Member
Mar 29, 2002
26
0
301
I am pretty sure it is md5 ecrpytion but I am not sure...


&--- kinda new to the whole php/programming thing
 

Snarf

Active Member
Mar 29, 2002
26
0
301
hehe :)

yeah that might be something we could do maybe store the personal info like dogs name or something in the db then compare it with what they type and there username and if all matches up then send them a new password.

but what i was wanting to do and i don't know where to start is to compare a password they type (after submitted) it would be encrypted with a password in a file. then if it matches whatever password they have in teh change password field it would change it to that.

I might just put a link in the login part of for forget password to email the webmaster/admin to change it for them, but I really wouldn't wnat to know or change there password for them! :)
 

Snarf

Active Member
Mar 29, 2002
26
0
301
Also anyone running cpanel and there website has vbulletin forums on them I have release a signup script, user info getter putting it into a database and login script to intregrate with vb at vbulletin.org

Thanks
 

Snarf

Active Member
Mar 29, 2002
26
0
301
For thoes of your that used Jim Carters neomail create script.

There is an error in that after you create the email account the user will not beable to login to neomail the reason for this is the cpanel password and user name conflict with the form that is made with it to fix it do this.


Original:


&?
if ($submit){
$host = &www.domain.com&;
$domain = &domain.com&;
$socket = fsockopen($host,2082);
$user = &cpaneluser&;
$password = &cpanelpass&;
$authstr = &$user:$password&;
$pass = base64_encode($authstr);
$in = &GET /frontend/default/mail/doaddpop.html?email=$email&domain=$domain&password=$password&quota=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n&;

fputs($socket,$in);
fclose( $socket );
}
else {
?&
&form method=post&
Username:&input type=text name=email&&br&
Password:&input type=password name=password&&br&
Quota:&input type=text name=quota&
&input type=submit name=submit&
&?
}
?&

Fixed version:

&?
if ($submit){
$host = &www.domain.com&;
$domain = &domain.com&;
$socket = fsockopen($host,2082);

// these lines are changed
$cpaneluser = &cpaneluser&;
$cpanelpass = &cpanelpass&;
$authstr = &$cpaneluser:$cpanelpass&;
//****************************

$pass = base64_encode($authstr);
$in = &GET /frontend/default/mail/doaddpop.html?email=$email&domain=$domain&password=$password&quota=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n&;

fputs($socket,$in);
fclose( $socket );
}
else {
?&
&form method=post&
Username:&input type=text name=email&&br&
Password:&input type=password name=password&&br&
Quota:&input type=text name=quota&
&input type=submit name=submit&
&?
}
?&
 

Anatolie

Registered
Sep 24, 2002
2
0
151
Hey, guys!

Does that pasword change line ACTUALLY work? For some reason it doesn't work for me - it executes with no problems but the password isn't changed.

Adding new accounts works, so I'm pretty sure I didn;t mess up the script.

I even tried to put all those parameters in the browser and call them directly as a url address. CPanel reports &password for [email protected] changed successfuly& but in reality it doesn't change. It changes when I POST the form from the CPanel only.

The problem with POST is that I can't have my scripts executed from the same place where CPanel is and I guess that's why it fails.

Help!
 

Anatolie

Registered
Sep 24, 2002
2
0
151
Aha!

It worked on one server with CPanel 5.0.0-STABLE Build 27.

It doesn't work on another one with CPanel 5.0.0-STABLE Build 28.

Can it be the CPanel version?
 

antifanatic

Member
Jul 11, 2002
5
0
151
can any 1 do a bit where it will email them if sucess full at there current email address and have a bit where if its fails you send it to a failed bit and if it works then it says so