Web Hosting Talk







View Full Version : Cpanel email signup via php


All-Starr 24-7
09-18-2004, 05:42 PM
Hey all,

I was wondering if there was anyway to make a php/html signup script that lets users sign up for an email account in cpanel.So basicly a form that lets people create an eamil at username@sitenmae.com.I know its possible, but im a php newbie, so i dont know how.Any help is greatly appreciated!:)

azizny
09-18-2004, 07:57 PM
You will need to use email client softwares there are maby avaiable for free..

search this fourm or hotscripts

peace,

gogocode
09-19-2004, 02:05 AM
Originally posted by All-Starr 24-7
Hey all,

I was wondering if there was anyway to make a php/html signup script that lets users sign up for an email account in cpanel.So basicly a form that lets people create an eamil at username@sitenmae.com.I know its possible, but im a php newbie, so i dont know how.Any help is greatly appreciated!:)

Fairly trivial, here is one, I havn't tested it but it should work ok unless I made a typo somewhere, just make a form on a page, set the action to the php file with the below code, and give it two fields 'email' and 'password', where email is just the username part of the email address (ie the bit before @). Change the relevant stuff, try it out.


<?php
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
$domain = 'example.com';
$quota = 2; // MB
$cpusername = 'cpanelUsername';
$cppassword = 'cpanelPassword';
$cpskin = 'xcontroller';

$request = "http://$cpusername:$cppassword@$domain:2082/frontend/$cpskin/poppadded.html";
$request .= "?email=" . rawurlencodedformat($email);
$request .= "&password=" . rawurlencodedformat($password);
$request .= "&domain=" . rawurlencodedformat($domain);
$request .= "&quota=" . $quota;

$response = implode('', file($request));

if(preg_match('/Following POP email account was added:/', $response))
{
?>
Yay! It Worked!
<?php
}
else
{
?>
Something bad she happen.
<?php
}
?>

lwknet
09-19-2004, 03:01 AM
there are so many outsourced email service provider, simply set your mx record to point to such provider and you'll be able to provide lots of features to thoseusers@yourdomain.com, virtually everything you can think of if they provide it

Mr. Obvious
09-19-2004, 11:37 AM
Heres my email thing.

<?php
// @@@ @@@
// @@@ @@@ cPanel Email Signup Script
// @@ © 2004 Tyler Weinrich. All Rights Reserved.

$cpanel_user = "Your cPanel Username"; // Cpanel Username
$cpanel_pass = "Your cPanel Password"; // Cpanel Password
$domain = "Your Domain"; // Website Domain
$xskin = "Your cPanel Skin"; // Cpanel Skin (Cant Find It? Look Where The Stars Are : http://www.domain.com:2082/frontend/****/)
$quota = "10"; // Quota
$smtpdomain = "Your SMTP Server"; // The Address Of The SMTP Server (smtp.domain.com, domain.com ect.)
$pop3domain = "Your POP3 Server"; // The Address Of The POP3 Server (pop3.domain.com, domain.com ect.)

// Don't Change Anything Below This Line

if($formfilled){
$ok = TRUE;
$file = fopen ("http://$cpanel_user:$cpanel_pass@$domain:2082/frontend/$xskin/mail/doaddpop.html?email=$NewEmail&domain=$domain&password=$Password&quota=$quota", "r");
if (!$file) {
$ok = FALSE;
$message = "Cannot Connect To The CPanel Server Files. Please Check The Config";
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
if (ereg ("already exists!", $line, $out)) {
$ok = FALSE;
$message = "That Email Address Is Allready Taken";
}
}
fclose($file);
if ($ok) {
$message = "Your Account Is Setup!<BR>";
$message .= "User : $NewEmail@$domain<BR>";
$message .= "Pass : $Password<BR>";
$message .= "POP3 : $pop3domain<BR>";
$message .= "SMTP : $smtpdomain<BR>";
$form_fields=array_keys($HTTP_POST_VARS);
$temp="\n";
while($field=array_pop($form_fields)){
$temp.=" $field : = $HTTP_POST_VARS[$field] \n";
}
mail($HTTP_POST_VARS['to'],"Free Email",$temp);
}
echo "$message";
}
else {
echo "<pre><form action=\"$PHP_SELF\" method=\"POST\">";
echo "Requested Email : <input name=\"NewEmail\">@$domain<BR>";
echo "Password : <input name=\"Password\"><BR><BR>";
echo "Quota : $quota<BR>";
echo "Submit : <input type=\"hidden\" value=\"dothef#@&inthing\" name=\"formfilled\"><input type=\"submit\" value=\"Get Your FreeMail\">";
echo "</form>";
}
?>