Jump to content

Changing a cpanel email password with a simple script.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
SeanStar

SeanStar

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
I was working tirelessly over this issue for about an hour...
My forum was set up so that if you donated you got an email and password as you requested - but it was through me... My email users wanted to change there email passwords. Since I was using my own email client script, I didn't want to reveal my hosters crappy webmail function from cpanel, thus I had to make a script to do it without logging into the webmail of cpanel. This is what I got.

(I searched google for this problem and never found a straight answer, so I had to figure it out myself. This might help other googler's in the future. ;P)


<html>

<body>

<form name="input" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

Email:<br />

<input type="text" name="email" />@example.com<br />

Password:<br />

<input type="password" name="pass" /><br />

New Password:<br />

<input type="password" name="newpass" /><br />

<input type="password" name="newpass2" /><br />

<input type="submit" value="Submit" />

</form>

<br />

<?php


$username = $_POST['email'];

$password = $_POST['pass'];

$cpaneldomain = 'example.com';

$email = $_POST['email'];

$emaildomain = 'example.com';

$newpass = $_POST['newpass'];


if($_POST['newpass']=="")

{

echo "";

}

else if($_POST['newpass']==$_POST['newpass2'])

{

echo "New password submitted.";

@file("http://$username@$emaildomain:$password@$cpaneldomain:2095/webmail/x/mail/dopasswdpop.html?redirectdomain=&email=$email&domain=$emaildomain&password=$newpass");

}

else

{

echo "The two new password fields must be the same.";

}

?>

</body>

</html>


Hope this helps some people with understanding the cpanel api and so forth.

Thanks.

#2
SeanStar

SeanStar

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
Feel free to rate it, or w/e. I want some feedback, as this is the first script I am releasing on this site. It is simple, but it works fine.

#3
sastro

sastro

    Newbie

  • Members
  • PipPip
  • 12 posts
Great job, maybe you should think to create a script to add domain to domain addon, add subdomain etc. to cpanel