Finally gave up SMTP way of sending email from my server and have a new code which works as stand alone but fails in the script.
The mail script which works is
<html>
<body>
<?
$myname = "webadmin";
$myemail = "webadmin@domain.com";
$contactname = "Contact";
$contactemail = "Srinip2002@yahoo.com";
$message = "Dear admin , This is a testing mail";
$subject = "Test Mail";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$myname." <".$myemail.">\r\n";
$headers .= "To: ".$contactname." <".$contactemail.">\r\n";
$headers .= "Reply-To: ".$myname." <$myreplyemail>\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";
mail($contactemail, $subject, $message, $headers);
?>
<center>Mail has been sent to <?echo $contactemail?></center>
</body>
</html>
The code which fails is this:
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<link href="color_scroll.css" rel="styleSheet" type="text/css">
</HEAD>
<BODY bgcolor=#9a0000>
<?php
include("header.inc");
include("email.inc");
$sRegistrationErr = "";
function tosql($value, $type="")
{
if($value == "")
return "NULL";
else
if($type == "Number")
return doubleval($value);
else
{
if(get_magic_quotes_gpc() == 0)
{
$value = str_replace("'","''",$value);
$value = str_replace("\","\\",$value);
}
else
{
$value = str_replace("\'","''",$value);
$value = str_replace("\\"","\"",$value);
}
return $value;
}
}
if ($REQUEST_METHOD=="POST") {
$fldfirst_name = tosql($FName, "Text");
$fldlast_name = tosql($LName, "Text");
$flduser_login = tosql($UName, "Text");
$fldemail = tosql($EMail, "Text");
$flduhq = tosql($UHQ, "Text");
$flduha = tosql($UHA, "Text");
$fldage = tosql($AGE, "Text");
$fldapt = tosql($APT, "Text");
}
# Random password generation
$length=8;
$all=explode(" ",
"a b c d e f g h i j k l m n o p q r s t u v w x y z "
. "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
. "0 1 2 3 4 5 6 7 8 9");
for($i=0;$i<$length;$i++) {
srand((double)microtime()*1000000);
$randy=rand(0, 61);
$pass.=$all[$randy];
}
$flduser_password = tosql($pass, "Text");
if(!strlen($flduser_login))
$sRegistrationErr .= "The value in field Login* is required.<br>";
if(!strlen($flduser_password))
$sRegistrationErr .= "The value in field Password* is required.<br>";
if (trim($fldapt) != "on")
$fldapt ="Not accept";
else
$fldapt ="Accept";
if($sRegistrationErr == "")
{
$SQL = "SELECT * FROM login where user_login = '$flduser_login'";
$result = mysql_query($SQL,$db);
$num=mysql_numrows($result);
if($num > 0){
echo "<br><br><br><center><font color=#ffff33 size=2 face=verdana><B>This user ID is already registered , please use some other user ID</B></font></center><br><br>";
echo "<center><input type=button value=Back onclick='javascript:history.go(-1)'></center>";
}
else {
$SQL1 = " insert into login ";
$SQL1 = $SQL1 . " (first_name,last_name,user_login,user_password,email,Hint_Question,Hint_Ans,age,acpt) values ";
$SQL1 = $SQL1 . " ('$fldfirst_name','$fldlast_name','$flduser_login','$flduser_password','$fldemail','$flduhq','$flduha','$fldage','$fldapt') ";
$result1 = mysql_query($SQL1,$db);
echo "<br><br><br><center><font color=#ffff33 size=2 face=verdana><B>Temporary random password has been sent to your email account, Please check to complete registration process..</B></font></center><br><br>";
echo "<center><form action='index.php'><input type=submit value=Home></center>";
echo "<B></B>";
//Sending Email to New Regitered User
$name = "admin";
$from = "webmater@domain.com";
$to = $fldemail;;
$subject = "Thank you for registering...!";
$body = "<html><body>Hi";
$body = $body . $fldfirst_name .",<br>";
$body = $body . "You have been Successfully Registered with us!<br>";
$body = $body . "User Id : ";
$body = $body . $flduser_login .",<br>";
$body = $body . "Password : ";
$body = $body . $flduser_password ."<br>";
$body = $body . "To complete registration, please click on the link below"."<br>";
$body = $body . "<a href=\"http://www.hearing-gone-bad.com/sri/Succ_reg.php?id=$flduser_login\">Click to complete regisration.</a></body></html>";
sendmail($name, $from, $to, $subject, $body, 1, "euc-kr");
}
}
else{
echo $sRegistrationErr;
}
?>
</body>
</html>
I do not get any error msgs. Help Pls.
Thanks
Sri