PDA

View Full Version : Automated Email Signup



JRitze
03-16-2006, 01:32 AM
I think i asked this before, but i don't remember if it was before or after the crash.

I want to setup emails for some people at my dads work but i want them to be able to fill out a form and it to automaticly create the email address.

There has got to be something...

JRitze
03-19-2006, 12:38 AM
There has to be something :(

Dave
03-19-2006, 02:57 AM
I got nothin' :o

areidmtm
03-19-2006, 01:04 PM
here is a quick and dirty way that I use.


<?php
/*
Create POP email accounts
Works for me when others failed.
*/
//include('header.php');

// Domain Logon Details
$username = "bluehost cpanel username here";
$password = "bluehost cpanel password here";

// Domain details
$domain = "domain name here";
$theme = "bluehost";

// Parameters to parse
$eDomain = "domain name here";
$eQuota = "10"; // in MB;

if (isset($delpop)) {
print "Account deleted : ".$popuser."@".$eDomain;

$postfields = "email=$popuser&domain=$eDomain";
$url = "http://$username:$password@$domain:2082/frontend/$theme/mail/realdelpop.html?$postfields";
//print "<hr>";
//print $url;
// initialise Curl
$popPost = curl_init();
curl_setopt($popPost, CURLOPT_URL, $url);
// Set Curl Option: Username:Password
curl_setopt($popPost, CURLOPT_POST, 1);
// Set Curl Option: Collect result from script
curl_setopt($popPost, CURLOPT_RETURNTRANSFER, 1);
// Set Curl Option: Set timeout to 15 seconds
curl_setopt($popPost, CURLOPT_TIMEOUT, 15);
// Set Curl Option: Post data
//curl_setopt($popPost, CURLOPT_POSTFIELDS, $postfields);
// Execute Request, and store result in $tb_post
$popPost_result = curl_exec ($popPost);
// Close Curl
curl_close ($popPost);
$start = strpos($popPost_result, 'Account');
$end = strpos($popPost_result, 'Go');
$subset = substr($popPost_result, $start, $end+8-$start);
print $substr;
}

if (isset($_POST['eEmail'])) {
$ePassword = $_POST['password2'];
// Put post fields variable together
$postfields = "email=" . $_POST['eEmail'] . "&domain=" . $eDomain . "&password=" . $ePassword . "&quota=" . $eQuota;
// initialise Curl
$popPost = curl_init();
// Set Curl Option: URL
$url = "http://" . $username . ":" . $password . "@" . $domain . ":2082/frontend/" . $theme . "/mail/doaddpop.html?" . $postfields;
curl_setopt($popPost, CURLOPT_URL, $url);
// Set Curl Option: Username:Password
curl_setopt($popPost, CURLOPT_POST, 1);
// Set Curl Option: Collect result from script
curl_setopt($popPost, CURLOPT_RETURNTRANSFER, 1);
// Set Curl Option: Set timeout to 15 seconds
curl_setopt($popPost, CURLOPT_TIMEOUT, 15);
// Set Curl Option: Post data
//curl_setopt($popPost, CURLOPT_POSTFIELDS, $postfields);
// Execute Request, and store result in $tb_post
$popPost_result = curl_exec ($popPost);
// Close Curl
curl_close ($popPost);

//output results
$start = strpos($popPost_result, '<b>Account');
$end = strpos($popPost_result, 'created.');
$subset = substr($popPost_result, $start, $end+8-$start);
$subset = str_replace('login ', "login<br>", $subset); //for neatness
//$subset=str_replace("<!",'<-',$subset); //see the comments
if (preg_match ('/Sorry/i', $subset)) {
print "<br><b>&nbsp;&nbsp;&nbsp;Sorry that account already exists.</b><br><br><br><br><br><br><br>";
//print ($subset);
} elseif(preg_match ('/You must specify/i', $subset)) {
print "<br><b>&nbsp;&nbsp;&nbsp;You must specify a password.</b><br><br><br><br><br><br><br>";
} else {
print ($subset);
print "<br><br>You may now use <b>mail." . $domain . "</b> as your POP3 setting in your mail client or access <b>WebMail</b> by selecting <a href=http://" . $domain . "/webmail>Here</a>.
<center>
<br><a href=javascript:history.go(-1)>Go Back</a>
</center>";
}
} else {
?>

<form name="emailform" method="post" action="index.php">
<table border="0" cellspacing="1" align=center cellpadding="0">
<tr>
<td>Prefered Email Address:</td>
<td colspan="2"><input size=10 value="" name="eEmail" type="text">
@<?= $domain ?></td>
</tr>
<tr>
<td>Password:</td>
<td colspan="2"><input size=10 name="password1" value="" type="password"></td>
</tr>
<tr>
<td>Retype Password:</td>
<td colspan="2"><input size=10 name="password2" value="" type="password"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="344"> <div align="center">
<input name="signupbtn" type="button" id="signupbtn" value="Signup" onClick="validateform()">
</div></td>
<td width="163">&nbsp;</td>
</tr>
</table>
<script language="JavaScript1.2">


function validateform() {
if (checkEmailAddress(document.emailform.eEmail)) {
if(document.emailform.password1.value == document.emailform.password2.value) {
document.emailform.submit();
}
else
{
alert("The passwords you typed do not appear to match");
}
}
}

function checkEmailAddress(field) {
var good;
//var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.go v)|(\.org)|(\..{2,2}))$)\b/gi);
var goodEmail = field.value;

if(goodEmail != "") {
//if (goodEmail){
good = true
} else {
alert('Please enter a valid e-mail address.')
field.focus()
field.select()
good = false
}
return good;
}


</script>
</form>
<? } ?>

JRitze
03-19-2006, 11:51 PM
Quick, Dirty and Not safe? or ?

areidmtm
03-20-2006, 08:57 AM
Yeah, it's probably not the safest way, but I've tried other ways, and none work. This was the only way. For me anyway, it's more of an administration type of thing. The public does not have access to this file. Although for you, the public would need to.

You could store your username and password in an encrypted DB and use SSL. That would be safer. Other than that, I dont know of any other safer way.

nhgpga.org
03-26-2006, 08:26 AM
I am also intrested in this... I found a script that is written in php (i will try and find it agian) but they didnt give the code out to "tewak" which I didnt know until I paid them for it and they stopped responding to emails!:mad: The php code is protected by some source protection. But it calles another file where your password information is stored.

twit
07-01-2008, 03:15 AM
The solution to your problem is qmail, supposedly yahoo mail is running on it as well. I am yet to install it because shell access still hasnt been enabled but from what I know its a little more than what you need but the extras wont hurt. There are different some varieties running around and I am about to install one called qmailrocks as it comes with a couple goodies prepackaged. Try it out and tell us what you think.

Ser Vaunt Premium
myspace.com/servaunt
servaunt.net
passionandhustle.com

lucknuts
07-11-2008, 05:01 PM
here is a quick and dirty way that I use.


<?php
/*
Create POP email accounts
Works for me when others failed.
*/
//include('header.php');

// Domain Logon Details
$username = "bluehost cpanel username here";
$password = "bluehost cpanel password here";

// Domain details
$domain = "domain name here";
$theme = "bluehost";

// Parameters to parse
$eDomain = "domain name here";
$eQuota = "10"; // in MB;

if (isset($delpop)) {
print "Account deleted : ".$popuser."@".$eDomain;

$postfields = "email=$popuser&domain=$eDomain";
$url = "http://$username:$password@$domain:2082/frontend/$theme/mail/realdelpop.html?$postfields";
//print "<hr>";
//print $url;
// initialise Curl
$popPost = curl_init();
curl_setopt($popPost, CURLOPT_URL, $url);
// Set Curl Option: Username:Password
curl_setopt($popPost, CURLOPT_POST, 1);
// Set Curl Option: Collect result from script
curl_setopt($popPost, CURLOPT_RETURNTRANSFER, 1);
// Set Curl Option: Set timeout to 15 seconds
curl_setopt($popPost, CURLOPT_TIMEOUT, 15);
// Set Curl Option: Post data
//curl_setopt($popPost, CURLOPT_POSTFIELDS, $postfields);
// Execute Request, and store result in $tb_post
$popPost_result = curl_exec ($popPost);
// Close Curl
curl_close ($popPost);
$start = strpos($popPost_result, 'Account');
$end = strpos($popPost_result, 'Go');
$subset = substr($popPost_result, $start, $end+8-$start);
print $substr;
}

if (isset($_POST['eEmail'])) {
$ePassword = $_POST['password2'];
// Put post fields variable together
$postfields = "email=" . $_POST['eEmail'] . "&domain=" . $eDomain . "&password=" . $ePassword . "&quota=" . $eQuota;
// initialise Curl
$popPost = curl_init();
// Set Curl Option: URL
$url = "http://" . $username . ":" . $password . "@" . $domain . ":2082/frontend/" . $theme . "/mail/doaddpop.html?" . $postfields;
curl_setopt($popPost, CURLOPT_URL, $url);
// Set Curl Option: Username:Password
curl_setopt($popPost, CURLOPT_POST, 1);
// Set Curl Option: Collect result from script
curl_setopt($popPost, CURLOPT_RETURNTRANSFER, 1);
// Set Curl Option: Set timeout to 15 seconds
curl_setopt($popPost, CURLOPT_TIMEOUT, 15);
// Set Curl Option: Post data
//curl_setopt($popPost, CURLOPT_POSTFIELDS, $postfields);
// Execute Request, and store result in $tb_post
$popPost_result = curl_exec ($popPost);
// Close Curl
curl_close ($popPost);

//output results
$start = strpos($popPost_result, '<b>Account');
$end = strpos($popPost_result, 'created.');
$subset = substr($popPost_result, $start, $end+8-$start);
$subset = str_replace('login ', "login<br>", $subset); //for neatness
//$subset=str_replace("<!",'<-',$subset); //see the comments
if (preg_match ('/Sorry/i', $subset)) {
print "<br><b>&nbsp;&nbsp;&nbsp;Sorry that account already exists.</b><br><br><br><br><br><br><br>";
//print ($subset);
} elseif(preg_match ('/You must specify/i', $subset)) {
print "<br><b>&nbsp;&nbsp;&nbsp;You must specify a password.</b><br><br><br><br><br><br><br>";
} else {
print ($subset);
print "<br><br>You may now use <b>mail." . $domain . "</b> as your POP3 setting in your mail client or access <b>WebMail</b> by selecting <a href=http://" . $domain . "/webmail>Here</a>.
<center>
<br><a href=javascript:history.go(-1)>Go Back</a>
</center>";
}
} else {
?>

<form name="emailform" method="post" action="index.php">
<table border="0" cellspacing="1" align=center cellpadding="0">
<tr>
<td>Prefered Email Address:</td>
<td colspan="2"><input size=10 value="" name="eEmail" type="text">
@<?= $domain ?></td>
</tr>
<tr>
<td>Password:</td>
<td colspan="2"><input size=10 name="password1" value="" type="password"></td>
</tr>
<tr>
<td>Retype Password:</td>
<td colspan="2"><input size=10 name="password2" value="" type="password"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="344"> <div align="center">
<input name="signupbtn" type="button" id="signupbtn" value="Signup" onClick="validateform()">
</div></td>
<td width="163">&nbsp;</td>
</tr>
</table>
<script language="JavaScript1.2">


function validateform() {
if (checkEmailAddress(document.emailform.eEmail)) {
if(document.emailform.password1.value == document.emailform.password2.value) {
document.emailform.submit();
}
else
{
alert("The passwords you typed do not appear to match");
}
}
}

function checkEmailAddress(field) {
var good;
//var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.go v)|(\.org)|(\..{2,2}))$)\b/gi);
var goodEmail = field.value;

if(goodEmail != "") {
//if (goodEmail){
good = true
} else {
alert('Please enter a valid e-mail address.')
field.focus()
field.select()
good = false
}
return good;
}


</script>
</form>
<? } ?>

That cant be safe at all. Including your cPanel info in an PHP script? Isn't that viewable to others?

lucknuts
07-11-2008, 05:59 PM
I've been trying for quite a while now to get that php script to even work. I have it embedded in an .php file although I...not sure whats goin on. I don't even think its logging into cPanel and creating it. "Obviously"