Web Hosting Talk







View Full Version : weird emails being sent


mulligan
08-12-2006, 11:44 AM
I keep getting these oddball emails being sent to me from our contacts page.

Here is a sample:

From: using7695@removed.xxx

Interests:

Subject: baconContent-Type: multipart/alternative; boundary=609287ad2517bcf115cd04b0767bcbb6Subject: curing requires immersing the ham in a brine for anbcc: buletmann@aol.com--609287ad2517bcf115cd04b0767bcbb6Content-Transfer-Encoding: 7bitContent-Type: text/plainusing a much higher temperature where the meat is partially cooked over a few days. *** produced bacon is cooked--609287ad2517bcf115cd04b0767bcbb6Content-Transfer-Encoding: 8bitContent-Type: text/plainwet dry curing recipe 3 xternal links edit ational regulation of ham production ach country that produces ham has its own regulations. edit rance ayonne am e--609287ad2517bcf115cd04b0767bcbb6--
Message: using7695@removed.xxx

Here is my php code... I have regex setup for subject etc... but they still seem to be able to send mail.

Any ideas why this is happening??

<?
function format_inputs($input) {
$input = str_replace("\n", "", $input);
$input = str_replace("\r", "", $input);
$input = str_replace("%0a", "", $input);
$input = str_replace("%0d", "", $input);
$input = trim(htmlentities($input));

return $input;
}

$email=$_POST["email"];
if (eregi("\r",$email) || eregi("\n",$email)){
die("Please do not spam. Attempt has been logged.");
}
else{
$interests=format_inputs($_POST['interests']);

$subject=format_inputs($_POST['subject']);

$message=format_inputs($_POST['message']);


if($message == ''){
die("Message was not entered");
}
if($subject == ''){
die("Subject was not entered");
}
if($email == ''){
die("Email was not entered");
}

$to="fake@email.com";

$message="\n\n From: $email\n Interests: $interests\n Subject: $subject \n Message: $message\n\n";

if(mail($to,$interests,$message,"From: $email\n")) {

echo "&nbsp;&nbsp;Thank you for contacting us. You are now being redirected to the main page.";

} else {

echo "&nbsp;&nbsp;There was a problem sending the mail. Please check that you filled in the form correctly.";

}
?>

URLsi
08-12-2006, 06:05 PM
I suggest this code:

<?php

$do=$_POST['do'];

if ($do == '') { ?>

<center><div id="content_medium" style="padding: 20px 20px 20px 20px; ">
<div style="background-color: #f7f7f7; "><br>Please use your real name and email address so that we can contact you back.<br><br></div>
<form name="mail" method="post" action="contact.php">
<input type="hidden" name="ip" id="ip" value="<? echo $ip; ?>" />
<div>Your Name<br />
<input name="realname" id="name" type="text" size="25" /></div>

<div>Your Email Address<br />
<input name="email" id="email" type="text" size="25" /></div>

<div>Subject<br />
<input name="subject" id="subject" type="text" size="25" /></div>

<div>Message<br />
<textarea name="message" cols="51" rows="10" id="message"></textarea></div>

<div >
<input type="hidden" name="do" value="1" />
<input name="Submit" type="submit" class="button" value=" Send Message " />
<input name="Reset" type="Reset" class="button" value=" Clear Form " />
</div>
</form>
</div></center><br>

<?
} else { //Start send mail

function isemail($email)
{
// regx to test for valid e-mail adres
$regex = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$';
if (eregi($regex, $email)) return true;
else return false;
}

//######### Pull form Data ##############//
$feed = "\r\n";
$recipent = "your@mail.com"; //Get the recipent from the form
$name = $_POST['realname']; //Get the name from the form
$address = $_POST['email']; //Get the email address from the form
$ip =$_POST['ip']; //Get the ip from the form
$subject = $_POST['subject'];
$subject .= " - ".$_POST['query']; //Get the subject from the form
$message = $_POST['message']; //Get the message from the form


//########## If EMAIL VALID, CHECK OTHER FIELDS THEN SEND MAIL ############//

If ((isemail($address) == true) && (strlen($name) > 1) && (strlen($message) > 1)) {

$full = $message.$feed.$feed.$name.$feed.$address.$feed.$ip; //combine info for message
$headers = 'From: '.$address;
mail($recipent, $subject, $full, $headers); //Send the email

//########### SUCCESSFUL MESSAGE SENT ##############//
echo "<center><div id='content_medium'>
<h1>Thank you.</h1><br>
Your message has been sent. We will contact you back asap!</div></center>";

} else {

//########### ERROR MESSAGE ##############//
echo "
<h2>Oops!</h2>
<p>It looks like you forgot something or you didn't provide a valid email address.
<br />
Please go back and complete all the fields.</p>
<p><a href='javascript: window.history.go(-1)'>Click here to return to the form</a></p>";

}
}
?>


all in one file...

mulligan
08-12-2006, 10:06 PM
Thanks, I'll give it a try.