View Full Version : PHP email loop problem
Curtisdw
01-21-2004, 01:23 PM
I have a form that users fill out - then on the submit button it processes a php script to email it to me. Is there something I'm missing in this script that would cause it to continue to loop. It started sending me blank emails after I got the first one?
OK Here is my script:
<?php
$myemail = "myemail@whatever.com";
if (!isset($visitormail))
echo "Somebody Goofed $ip" ;
$todayis = date("l, F j, Y, g:i a") ;
$subject = "Visitor Mail" ;
$message = " $todayis [EST] \n
From: $visitor ($visitormail)\n
Message: $notes \n
-------------------------------------|
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $myemail\r\n";
if ($myemail != "")
mail($myemail, $subject, $message, "From:"$visitormail);
?>
Viper007Bond
01-21-2004, 02:32 PM
You need a period between "From:" and $visitormail, like this:
"From:".$visitormailThe period unions the two.
y6y6y6
01-21-2004, 02:34 PM
Shouldn't this be:
mail($myemail, $subject, $message, $from);
Not sure what "From:"$visitormail would do there, but it can't be good.
Viper007Bond
01-21-2004, 02:52 PM
Umm, it's quite fine actually. That's the idea of the commas - they seperate the parts of the mail function.
I take it you don't know PHP. ;)
Curtisdw
01-21-2004, 03:02 PM
I'm still learning, yes, thank you.
But looking at my code I didn't think there was anything that would cause it to continue to loop. Would this be a server problem?
Viper007Bond
01-21-2004, 03:09 PM
What do you mean it's looping? It's sending tons of e-mails? Try doing it the correct way with brackets and see if that helps:
<?php
$myemail = "myemail@whatever.com";
if (!isset($visitormail)) { echo "Somebody Goofed $ip"; }
$todayis = date("l, F j, Y, g:i a") ;
$subject = "Visitor Mail" ;
$message = " $todayis [EST] \n
From: $visitor ($visitormail)\n
Message: $notes \n
-------------------------------------|
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $myemail\r\n";
if ($myemail != "") { mail($myemail, $subject, $message, "From:".$visitormail); }
?>And I was talking to y6y6y6 when I said "you don't know PHP, do you?". ;)
Viper007Bond
01-21-2004, 03:12 PM
Okay, WTF? This thread has 1000+ views...
Curtisdw
01-21-2004, 03:36 PM
ok I just saw the view count ...thats really wierd. It is starting to freak me out and make me wonder if there is something screwy going on with my system.
y6y6y6
01-21-2004, 03:46 PM
"From:"$visitormail
Comma? What comma?
Viper007Bond
01-22-2004, 02:21 AM
Originally posted by y6y6y6
"From:"$visitormail
Comma? What comma?
*sigh*
There is comma before that which sperates it from the message and tell the main funtion it is part of the headers.
The period between the text and the variable is needed to union it.
For example:
$var1 = "this is some text";
$var2 = "some more text";
$var 3 = $var1.$var2;
echo $var3;
That would produce:
this is some textsome more text
Follow?
vBulletin® v3.7.0, Copyright ©2000-2010, Jelsoft Enterprises Ltd.