Reputation: 25
I'm new to php and I have a form that needs to get information and send it to me by mail. The problem is that sometimes I receive email containing only an IP adress and nothing else. I tried pressing "send" without entering anything in the fields and I receive an email containing everything else but the answers to the questions, so that is not the case it seems. My questions is why do I receive email containing only an IP adress? Thanks!
<?php
$to = "[email protected]";
$subject = "energiebio contact form: {$_POST['ams']['Destination']} ";
$from = $_POST['ams']['E-mail'];
$valid=1;
$message ='';
foreach ($_POST['mas'] as $k=>$v){
if (trim($v)=='')$valid=0;
$k = str_replace('_',' ',$k);
$message .="$k : $v<br>";
}
$message .="<hr />IP: {$_SERVER['REMOTE_ADDR']}";
function sndmail($from,$to,$subject,$message){
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From:".$from ."\r\n";
mail($to, $subject, $message, $headers);
}
if ($valid=='1') {
sndmail($from,$to,$subject,$message);
header( 'Location: http://site.ro/danke.html' ) ;
}else header( 'Location: http://site.ro/error.html' ) ;
?>
I've discovered that it's the same IP and that I can't get a "whois" on it the same: 92.85.174.105
Upvotes: 1
Views: 149
Reputation: 53553
I'd say something, for example google bot or a spam bot, is hitting your email script without using your form. If you have HTML like this:
<form action="postmail.php">
<!-- stuff -->
a script can just hit your "postmail.php" without using the send button. Then body content would be empty, and you'd get an empty email containing nothing but the senders ip.
Upvotes: 1