Results 1 to 25 of 32
-
03-27-2004, 03:59 PM #1Junior Guru Wannabe
- Join Date
- Mar 2004
- Location
- In The Tree Outside Your Bedroom Window
- Posts
- 37
Automatically create just an email address in Cpanel
After lurking for close to a month now I would like to say thank you for all that I have learned here. I recently upgraded hosts to a reseller with WHM/Cpanel.
My question is how do I automatically create just an email address in Cpanel? I would like to have a form that my registered users fill out and an email would be automatically created in my domain. Is this even possible?
I think I am pretty savvy when it comes to PHP so I thought a look through the cPanel Accounting PHP module API would help. This documentation is really lacking. It is called the cPanel Accounting PHP module, but it is really a WHM Accounting PHP module. I see the routines to create an account, but only in the WHM.
I have looked at PHPCoin, and other to see if I could 'borrow' some code from them, but it looks like they all deal with WHM and not the domain specific Cpanel.
Any ideas?
-
03-27-2004, 04:34 PM #2Disabled
- Join Date
- Dec 2003
- Posts
- 467
this is not exactly possibly within Cpanel.
The only thing you can do is Get some software like Socketmail or Hivemail.
That type of software uses the "Catch all" email account and then distributes the email to the webmail client users.
Sadly i dont think they use POP or IMAP
-
03-27-2004, 04:48 PM #3Web Hosting Master
- Join Date
- Aug 2003
- Posts
- 2,733
I use Cpanel/WHM and I don't believe it's possible right now
-
03-27-2004, 05:04 PM #4Junior Guru Wannabe
- Join Date
- Mar 2004
- Location
- In The Tree Outside Your Bedroom Window
- Posts
- 37
I did not think so either, but I thought I would ask.
-
03-27-2004, 06:12 PM #5Junior Guru Wannabe
- Join Date
- Nov 2002
- Posts
- 53
Here is something I used for a project I did a few months ago:
"Cpanelmail is a small script to let users create their own email accounts without you having to do a thing. "
http://lucidstorm.com/scripts.php
My programmer had to tweak it a bit to get it to work with our application, but it ended up giving him all the info he needed to see how to create email accounts outside of Cpanel.
Good luck and report back if / when you find something!
-
03-27-2004, 08:28 PM #6Junior Guru Wannabe
- Join Date
- Jul 2003
- Posts
- 53
Well, it can be done As matter of fact I did this.The user fills in a form with desired username, password and the script creates and email for him using Cpanel.
PM me if interested in this solution
Thank you
-
03-27-2004, 09:03 PM #7Junior Guru Wannabe
- Join Date
- Mar 2004
- Location
- In The Tree Outside Your Bedroom Window
- Posts
- 37
danyprundus,
I am interested in this if it is a free solution. Not sure I can afford much. I tried to PM you, but I get access denied. Oh well. Could you email me the detail or post a link here on the board?
-
03-28-2004, 03:04 AM #8New Member
- Join Date
- Mar 2004
- Posts
- 4
this is something i would like to have also if i can and its free. can't do much at this time for money. i don't want to signup for your other srevices becaus ei have my own already. sorry.
-
03-28-2004, 04:29 AM #9Junior Guru Wannabe
- Join Date
- May 2003
- Posts
- 78
WHM/Cpanel always creates a default email with login username and password.
In fact I had the the opposite problem you do awhile back. I wanted to find out how to make Cpanel not create an email address. I was going to offer free hosting without email but couldn't find a way to stop it from creating an email.
If you need it to create a specific email thats a different story.
-
03-28-2004, 04:38 AM #10Junior Guru Wannabe
- Join Date
- Mar 2004
- Location
- In The Tree Outside Your Bedroom Window
- Posts
- 37
After looking at Cpanel and how it passes URL I was able to Goggle up a thread at hosting-unlimited.net's forums. I tested the code and it works!!! Very simple, but I can put a MySQL database on the back end so I get no dups. Here is the code:
PHP Code:<?
if ($submit){
$host = "domainName minus the [url]www.[/url]";
$port = 2082;
$path = "/frontend/x2/mail/doaddpop.html"; //or .dll, etc. for authnet, etc.
// these lines are changed
$cpaneluser = "Cpanel Username";
$cpanelpass = "Cpanel Password";
$authstr = "$cpaneluser:$cpanelpass";
//****************************
// Setup the Auth String
$pass = base64_encode($authstr);
//Setup an array of all the POST data
$formdata = array ( "email" => $email, "domain" => $host, "password" => $password, "quota" => $quota);
//build the post string
foreach($formdata AS $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
}
// strip off trailing ampersand
$poststring = substr($poststring, 0, -1);
$fp = fsockopen($host, $port, $errno, $errstr, $timeout = 30);
if(!$fp){
//error tell us
echo "$errstr ($errno)\n";
}else{
//send the server request
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Authorization: Basic $pass \r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
//*************************************
// Remove this to stop it from displaying the output fron the CPanel
//*************************************
//loop through the response from the server
while(!feof($fp)) {
echo fgets($fp, 4096);
}
//close fp - we are done with it
fclose($fp);
}
print "Email Account Created";
}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" value="true">
<? } ?>
-
03-28-2004, 10:49 AM #11Junior Guru Wannabe
- Join Date
- Jul 2003
- Posts
- 53
Hehe, yes, something like that. Solutions aren't always complicated. Anyway I'm still interested in any projects you might have
-
03-28-2004, 07:49 PM #12Junior Guru Wannabe
- Join Date
- Nov 2002
- Posts
- 53
Well... I'll be! It actually worked... (had to change the "/frontend/x2/mail/doaddpop.html" to ""/frontend/bluelagoon/mail/doaddpop.html"
Now, for those of us (me) that aren't programming inclined, how do I ensure that my cpanel pass, etc. aren't out there to be viewed? Also, the results page had a bunch of missing Cpanel images... any way to fix this?
Thanks suiso! Not a bad post for a "newbie"!!!
-
03-28-2004, 08:42 PM #13Junior Guru Wannabe
- Join Date
- Mar 2004
- Location
- In The Tree Outside Your Bedroom Window
- Posts
- 37
Boy reviewum.com, you should talk
The best way to ensure that your cpanel pass/account is secure is to move that to a config file outside your webroot and call it in the main script file like this:
PHP Code:$host = "domain.name"; //your domain name
$port = 2082;
$path = "/frontend/x2/mail/doaddpop.html"; //change x2 to your theme.
$cpaneluser = "Cpanel Username";
$cpanelpass = "Cpanel Password";
$authstr = "$cpaneluser:$cpanelpass";
Now remove these lines from the main script and add:
PHP Code:include("../config.php");
PHP Code:while(!feof($fp)) {
echo fgets($fp, 4096);
}
-
03-28-2004, 08:56 PM #14Junior Guru Wannabe
- Join Date
- Nov 2002
- Posts
- 53
I'm surprised there aren't a million of these cpanel / email scripts already out there, not to mention one that uses a flat file or mysql DB to check if an account already exists, etc.
suiso, keep up the great work! I'd love to see the final version!
-
03-28-2004, 09:23 PM #15Junior Guru Wannabe
- Join Date
- Mar 2004
- Location
- In The Tree Outside Your Bedroom Window
- Posts
- 37
You pointed me in the right dirction. Cpanelmail does just that, but they want money for it. After seeing how Cpanel passes the URL and how MySQL backend whould check for accounts, thanks to Cpanelmail, this just got the ball rolling.
I would love to post a finished link to the code here IF I finish it, but I am no PHP guru. Right now content is king on my sites and not function. Til then......
-
03-29-2004, 08:57 AM #16Newbie
- Join Date
- Mar 2004
- Posts
- 19
Check this doc. Haven't tried it myself, but seems to be ok to work
omidsoft.com/tutorial/create_mailbox_cpanel
-
05-25-2004, 08:50 AM #17Newbie
- Join Date
- May 2004
- Posts
- 5
Suiso, i'm having some trouble with your code.. Although, you say to remove this line..
Code:while(!feof($fp)) { echo fgets($fp, 4096); }
Code:print "Email Account Created";
Partie™
Partie™
-
05-26-2004, 05:27 AM #18Junior Guru Wannabe
- Join Date
- May 2004
- Posts
- 66
Actually i made it with php in only 2 lines
and i ve been 1 year using it without anybugs , we have a site where users can automatically creat their emails
It seems we have some weak php developers around here !!
If any body needs it , you can demand it .....(sure 4 free)
-
05-26-2004, 05:39 AM #19Junior Guru Wannabe
- Join Date
- Jun 2002
- Location
- Perth, Australia
- Posts
- 85
Has anyone tried a method similar to this to change a cpanel user's password?
Also, it would be handy if we could update a cpanel user's contact email address too.
I'm sure its possible using a script similar to suiso's - I might give it a try sometime.
James
-
05-26-2004, 05:59 AM #20Junior Guru Wannabe
- Join Date
- May 2004
- Posts
- 66
you can use something like this in your code
<?
file("http://username:password@http://www.yoursite.com:2082/fronten....com&password=$password
&quota=20&submit=create&email=$username");
?>
it is the easiest way
-
05-27-2004, 04:11 AM #21Newbie
- Join Date
- May 2004
- Posts
- 5
This is why I hate asking for programming help. Most programmers won't help you unless you've been in their "clique" for years and when someone finally does ask for help they're ridiculed for asking. So, next time when a specific question is asked, how about not giving me an opinion and just giving me a solution or a pointer for my problem.
Thanks.
Partie™
-
05-27-2004, 06:31 AM #22Junior Guru
- Join Date
- Mar 2004
- Posts
- 248
cut and dry way....
PHP Code://////////////////////////////////////////////////////
// Create email address on the fly //
//////////////////////////////////////////////////////
$host = "www.whatever.com";//your url
$domain = "whatever.info";//your domain without the www
//Cpanel options:
$cpaneluser = "xxxx";//your cpanel username
$cpanelpass = "xxxx";//your cpanel password
$cpaneltheme= "x"; //this is the word after frontend/ and the next / when you login to cpanel
$spacequota=128;//how much space in k you want to give the user
// move the above to a config.php file then call it below
//include("../mailconfig.php");
$socket = fsockopen($host,2082, $err1, $err2, 30);
socket_set_timeout($socket, 30);
$authstr = "$cpaneluser:$cpanelpass";
$pass = base64_encode($authstr);
$in = "GET /frontend/x/mail/doaddpop.html?email=$row[username]&domain=comain.com&password=$old_password"a=1\r\n HTTP/1.0\r\nHost: $host\r\nConnection: Keep-Alive\r\nAuthorization: Basic $pass \r\n\r\n";
fputs($socket,$in);
//test data////////
$var1 = fgets($socket);
if (substr_count($var1, "200 OK") > 0)
{
$var2 = false;
while ( !$var2)
{
$var1=fgets($socket);
if ($var1 == false)
$var2 = true;
}
//return $socket;
}
else if (strlen($var1) < 15)
{
fclose($socket);
//return -1;
}
else
{
fclose($socket);
//return 0;
}
fclose( $socket );
//////////////////////////////////////////////////////
// end creating email address //
//////////////////////////////////////////////////////
-
05-27-2004, 07:19 AM #23Newbie
- Join Date
- May 2004
- Posts
- 5
Thanks a lot joe, I actually figured out my problem ON MY OWN...no thanks to naguib2000 but I do appreciate the code that you have posted. My problem was the person that posted the earlier code said to take out a line to stop it from displaying the output from cpanel, when i did that, it wouldn't work...so, I did some studying up on some of the different things he used and found all I had to do was delete the "echo" lmao, sad, but true...
Partie¢À
-
05-27-2004, 09:03 AM #24Junior Guru
- Join Date
- Mar 2004
- Posts
- 248
ya under the //test data comments is the delay waiting for the response from cpanel... a cpanel update not to long ago required this for the script to work. I had to find that the hard way too.
your welcome for the code... i found it for free, and don't feel charging for it would be right... FYI it was buried in the cpanel forums about needed to wait for the cpanel response
-
05-30-2004, 09:41 AM #25Newbie
- Join Date
- May 2004
- Posts
- 5
Ok guys and dolls. Not too sure who would care to read what I'm about to say, but for those of you who use phpBB I've actually created a phpbb MOD out of the code Suiso provided. If you'd like to take a look @ it either reply here or send me a PM. As of this writing Version = 2.1.0
Also, you can look at the initial release of my MOD at phpbbhacks.com
Moderators of this forum...sorry if this isn't allowed, if it's not please delete/edit this post as needed.
Thanks again to everyone that helped and posted the initial code!
Partie™