mail sent automatically even i do not write email id
Posted: Tue Nov 25, 2008 7:36 am
hi
can anyone help me ,this code is working even i do not write email id
email.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$fromerror="";
$emailerror="";
if (!empty($_POST['Submit']))
{
$checkmail=(trim($_POST['to']));
if ($checkmail=="")
{
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $checkmail))
{
echo "Invalid email in <b>To </b>, please enter valid email id"."<br>";
}
$checkfrom=(trim($_POST['from']));
if ($checkfrom=="")
{
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $checkfrom))
{
echo "Invalid email in <b>From</b>, please enter valid email id"."<br>";
}
}
?>
<?php echo $emailerror; ?>
<?php echo $fromerror; ?>
<table>
<form name="theform" method="post" action="sendmail.php">
<tr>
<td width="97">To</td>
<td width="160"><input type="text" name="to" size="26" id="to" value="<?php echo $_POST['to'] ?>"/></td>
</tr>
<tr>
<td>From</td>
<td><input type="text" name="from" size="26" value="<?php echo $_POST['from'] ?>"/></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="subject" size="26" /></td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="message"></textarea></td>
</tr>
<tr>
<td><input type="Submit" value="Submit" name="Submit"/>
<input type="reset" value="Reset" /> </td>
</tr>
</table>
</form>
</body>
</html>
sendmail.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
error_reporting(E_ALL ^ E_NOTICE);
// Include Class
include("class.phpmailer.php");
// Variable Declaration....
$to="";
$from="";
$subject="";
$mailsent="";
$message="";
$to = $_POST["to"];
$from = $_POST["from"];
$subject = $_POST["subject"];
$message = $_POST["message"];
//Mail sending settings....
$mail = new PHPMailer();
$body = $message = $_POST["message"];
$mail->IsSMTP();
$mail->SMTPAuth = false;
$mail->Host = "Aditya10";
$mail->Port = 258;
$mail->Username = "test";
$mail->Password = "test";
$mail->AddReplyTo("test@adityainfotech.com","prameet");
$mail->From = $_POST["from"];
$mail->FromName = "prameet";
$mail->Subject = $_POST["subject"];
$mail->Body = $message = $_POST["message"];
$mail->AddAddress("test@adityainfotech.com", "naresh");
$mail->IsHTML(true);
// Condition Checking...
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
can anyone help me ,this code is working even i do not write email id
email.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$fromerror="";
$emailerror="";
if (!empty($_POST['Submit']))
{
$checkmail=(trim($_POST['to']));
if ($checkmail=="")
{
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $checkmail))
{
echo "Invalid email in <b>To </b>, please enter valid email id"."<br>";
}
$checkfrom=(trim($_POST['from']));
if ($checkfrom=="")
{
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $checkfrom))
{
echo "Invalid email in <b>From</b>, please enter valid email id"."<br>";
}
}
?>
<?php echo $emailerror; ?>
<?php echo $fromerror; ?>
<table>
<form name="theform" method="post" action="sendmail.php">
<tr>
<td width="97">To</td>
<td width="160"><input type="text" name="to" size="26" id="to" value="<?php echo $_POST['to'] ?>"/></td>
</tr>
<tr>
<td>From</td>
<td><input type="text" name="from" size="26" value="<?php echo $_POST['from'] ?>"/></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="subject" size="26" /></td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="message"></textarea></td>
</tr>
<tr>
<td><input type="Submit" value="Submit" name="Submit"/>
<input type="reset" value="Reset" /> </td>
</tr>
</table>
</form>
</body>
</html>
sendmail.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
error_reporting(E_ALL ^ E_NOTICE);
// Include Class
include("class.phpmailer.php");
// Variable Declaration....
$to="";
$from="";
$subject="";
$mailsent="";
$message="";
$to = $_POST["to"];
$from = $_POST["from"];
$subject = $_POST["subject"];
$message = $_POST["message"];
//Mail sending settings....
$mail = new PHPMailer();
$body = $message = $_POST["message"];
$mail->IsSMTP();
$mail->SMTPAuth = false;
$mail->Host = "Aditya10";
$mail->Port = 258;
$mail->Username = "test";
$mail->Password = "test";
$mail->AddReplyTo("test@adityainfotech.com","prameet");
$mail->From = $_POST["from"];
$mail->FromName = "prameet";
$mail->Subject = $_POST["subject"];
$mail->Body = $message = $_POST["message"];
$mail->AddAddress("test@adityainfotech.com", "naresh");
$mail->IsHTML(true);
// Condition Checking...
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>