How do I implement this idea...
Posted: Thu Oct 17, 2002 5:55 pm
I have this script which allows people to sign up for an e-mail forwarding account at my domain:
It works correctly and everything, but i have been getting people just filling in any old junk for the forward to address, so I was wondering if it is possible to implement some form of mx records check so that if i sign up and use the e-mail address 'me@something.com' it will come back with something like 'We successfully connected to something.com (216.180.224.178) and confirmed that it's a genuine mail server'
or
i sign up with 'idiot@hotmail.com' it will come back with 'We successfully connected to mx2.hotmail.com (65.54.252.230) and confirmed that it's a genuine mail server.'
then it will continue and create the forwarding account.
But if it encounters and error like the mailbox is full it will come back with 'We were unable to find a way to deliver mail to the address you gave us (idiot@hotmail.com). Please verify that you entered it correctly.
Here's what your MX host said to us when we tried to talk to it:
552 Requested action not taken: exceeded storage allocation '
or if the e-mail address is fake like: lalala@sumpheiosmcdd.com it will come back with 'We were unable to find a way to deliver mail to the address you gave us (lalala@sumpheiosmcdd.com). Please verify that you entered it correctly. Technical: We couldn't find an MX record for your domain.' and then it will stop the signup process and ask you to re-enter your correct e-mail address.
If anyone could implement this for me it would be much appreciated.
note: php n00B (about a month) so a completed script, or step-by-step instructions would be appreciated.
Kind regards,
-Tubby.
Code: Select all
<?php
$pathtoconfig="config.php";
include("theme.php");
doheader();
if(isset($newuser))
{
include($pathtoconfig);
$newemail = "$newuser@$domain";
$mpassword = $password2;
$link = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname) or die("Could not select database");
$query="SELECT username FROM $dbtable WHERE((username = '$newuser'))";
$result= mysql_query($query,$link);
if(mysql_num_rows($result) == 0)
{
$query="INSERT INTO $dbtable(name,username,password,email) VALUES ('$name','$newuser','$password2','$replymail');";
mysql_query($query,$link);
$socket = fsockopen($host,2082);
$authstr = "$cpaneluser:$cpanelpass";
$pass = base64_encode($authstr);
if($emailtype=="mailbox") {
$in = "GET /frontend/$cpaneltheme/mail/doaddpop.html?email=$newemail&domain=$domain&password=$mpassword&quota=$quota\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";
fputs($socket,$in);
}
if($emailtype=="forwarding") {
$in = "GET /frontend/$cpaneltheme/mail/doaddfwd.html?email=$newuser&domain=$domain&forward=$replymail\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";
fputs($socket,$in);
}
fclose( $socket );
if($emailtype=="mailbox") {
echo "Your account has been setup successfully! Please <a href="index.php">login here</a> to setup your account";
}
if($emailtype=="forwarding") {
echo "Your e-mail forwarding account has been setup successfully! If you have any questions, feel free to contact us. <a href="index.php">Return to E-Mail Home</a>";
}
}
else {
echo "The username "$newuser" is already in use. Please try another one.<br><a href=signup.php>Back</a>";
}
mysql_close($link);
}
else {
include($pathtoconfig);
if($emailtype=="mailbox") {
echo "<form name="orderform" method="post" action="signup.php"><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="100%" id="AutoNumber1">
<tr>
<td>
<div align="center">
<center><br><br><br><br><br><br><br><br><br>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1">
<tr>
<td width="50%">Your full Name:</td>
<td width="50%"><input name="name" type="text" size="20"></td>
</tr>
<tr>
<td width="50%">Other Email Address:</td>
<td width="50%"><input name="replymail" type="text" size="20">(In case
you forget your password)</td>
</tr>
<tr>
<td width="50%">Prefered Email Address:</td>
<td width="50%"><input name="newuser" type="text" size="20">@$domain</td>
</tr>
<tr>
<td width="50%">Password:</td>
<td width="50%"><input name="password1" type="password" size="20"></td>
</tr>
<tr>
<td width="50%">Retype Password:</td>
<td width="50%"><input name="password2" type="password" size="20"></td>
</tr>
<tr>
<td width="50%">&nbsp;</td>
<td width="50%">
<input name="signupbtn" type="button" id="signupbtn" value="Signup" onClick="validateform()" size="20">
</td>
</tr>
</table></center>
</div>
&nbsp;</td>
</tr></table>
<script language="JavaScript1.2">
function validateform()
{
if (checkEmailAddress(document.orderform.replymail))
{
if(document.orderform.password1.value == document.orderform.password2.value)
{
document.orderform.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)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail){
good = true
} else {
alert('Please enter a valid e-mail address.')
field.focus()
field.select()
good = false
}
return good;
}
</script>
</form>";
}
}
if($emailtype=="forwarding") {
echo "<form name="orderform" method="post" action="signup.php"><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="100%" id="AutoNumber1">
<tr>
<td>
<div align="center">
<center><br><br><br><br><br><br><br><br><br>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1">
<tr>
<td width="50%">Your full Name:</td>
<td width="50%"><input name="name" type="text" size="20"></td>
</tr>
<tr>
<td width="50%">E-mail address to forward to:</td>
<td width="50%"><input name="replymail" type="text" size="20"></td>
</tr>
<tr>
<td width="50%">E-mail address to forward from:</td>
<td width="50%"><input name="newuser" type="text" size="20">@$domain</td>
</tr>
<tr>
<td width="50%">&nbsp;</td>
<td width="50%">
<input name="signupbtn" type="submit" id="signupbtn" value="Signup" size="20">
</td>
</tr>
</table></center>
</div>
&nbsp;</td>
</tr></table>
</form>";
}
dofooter();
?>or
i sign up with 'idiot@hotmail.com' it will come back with 'We successfully connected to mx2.hotmail.com (65.54.252.230) and confirmed that it's a genuine mail server.'
then it will continue and create the forwarding account.
But if it encounters and error like the mailbox is full it will come back with 'We were unable to find a way to deliver mail to the address you gave us (idiot@hotmail.com). Please verify that you entered it correctly.
Here's what your MX host said to us when we tried to talk to it:
552 Requested action not taken: exceeded storage allocation '
or if the e-mail address is fake like: lalala@sumpheiosmcdd.com it will come back with 'We were unable to find a way to deliver mail to the address you gave us (lalala@sumpheiosmcdd.com). Please verify that you entered it correctly. Technical: We couldn't find an MX record for your domain.' and then it will stop the signup process and ask you to re-enter your correct e-mail address.
If anyone could implement this for me it would be much appreciated.
note: php n00B (about a month) so a completed script, or step-by-step instructions would be appreciated.
Kind regards,
-Tubby.