mail sent automatically even i do not write email id

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nnnpuri
Forum Newbie
Posts: 14
Joined: Tue Nov 25, 2008 6:50 am

mail sent automatically even i do not write email id

Post by nnnpuri »

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>
EWebSolutions0
Forum Newbie
Posts: 1
Joined: Thu Nov 21, 2013 1:42 am

Re: mail sent automatically even i do not write email id

Post by EWebSolutions0 »

but this code not ok please check code Agnes.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: mail sent automatically even i do not write email id

Post by Celauran »

Code: Select all

$mail->AddAddress("test@adityainfotech.com", "naresh");
You've got an email address hard coded.
Post Reply