Log in

View Full Version : Form submissions caught in bulk folder



hurricanebob
04-17-2007, 03:33 AM
Help! I don't know anything about php forms. I'm building a simple website for a buddy, and he wants a simple "Join our mailing list" form on his site.

His web hosting company (Go-Daddy) has a php form feature that I was able to setup and configure to send an email to me with the data submitted by the user.

PROBLEM:

The emails from the form/php script get caught in the bulk/spam folder instead of going to my inbox. I flagged the message as "not spam" which included the address on the "white list" so future emails would go to the inbox. Unfortunately, the php form automatically takes the contents of the "email address" field and plugs it into the "FROM" field of the message, so EVERY MESSAGE FROM THE WEBSITE COMES FROM A DIFFERENT EMAIL ADDRESS, making it impossible to mark them as "not spam".

Is there a way to specify the same "from" address every time an email is sent from the website? If so, what is the syntax to specify this? Is it done in the HTML of the page, or does it have to be done in the gdform.php script?

I already put in a support ticket with Go-Daddy, and they said "You could indeed modify the form in such a way, but it would require custom coding that we unfortunately aren't allowed to troubleshoot. You may be able to find such coding using your search engine of choice, however. Please let us know if we can help you in any other way." Thanks guys!

Any help would be greatly appreciated.

Thanks in advance,

HB

Note - the source code I used for the form is below if it helps any.


Source Code:

<form action="gdform.php" method="post">
<input type="hidden" name="subject" value="Form Submission" />
<input type="hidden" name="redirect" value="thankyou.htm" />
<input type="hidden" name="subject" value="Mailing List request" />


<div align="center">
<center>
<table border="0" cellpadding="4" width="90%">
<tr>
<td width="30%" align="right">* Email:</td>
<td width="70%"><input type="text" name="Email" size="54">&nbsp;(required)</td>
</tr>
<tr>
<td width="30%" align="right">Name:</td>
<td width="70%"><input type="text" name="Name" size="54"></td>
</tr>
<tr>
<td width="30%" align="right">Address:</td>
<td width="70%"><input type="text" name="Address" size="54"></td>
</tr>
<tr>
<td width="30%" align="right">City, State, Zip:</td>
<td width="70%"><input type="text" name="City" size="25">&nbsp;&nbsp;
<input type="text" name="State" size="4">&nbsp;&nbsp;
<input type="text" name="Zip" size="12"></td>
</tr>
<tr>
<td width="30%" align="right"></td>
<td width="70%"></td>
</tr>
<tr>
<td width="30%" align="right" valign="top">Comments:</td>
<td width="70%"><textarea rows="6" name="Comments" cols="42"></textarea></td>
</tr>
</table>
</center>
</div>
<p align="center"><input type="submit" name="submit" value="submit"/>
</p>
</form>

thetestingsite
04-17-2007, 04:18 AM
If you had access to the php script, you could specify (in the headers of the message) what email address you were sending from. Without that, there's nothing more that we can help with.

Hope this helps.

//EDIT: on a side note, Go Daddy's support is never helpful.

djr33
04-17-2007, 02:10 PM
I agree with both points above (incl. godaddy not being supportive :p).

If you know what you're doing with the php code, you could just include as the fourth parameter of the mail() function the header for from.... "From: automailer@mysite.com"
(I believe that is all you need, though it would need to be formatted to work with other additional headers, like reply-to and x-mailer, etc.)

As for godaddy specifically, I'm not aware of any PHP mail scripts. they might have something, but I think it's just CGI, if anything. If you say you're using PHP, though, that's fine. I'm just not sure what you're referring to. Is this an option available in the cpanel?

boxxertrumps
04-17-2007, 03:44 PM
impossible to mark them as "not spam".
Uhhh... Noone likes spam, and they might just blacklist your domain.
Also, filters look for certain words in the mail, and if the phrase "bank of africa" and other known phishing/spam fodder is present, then the filter wont accept your mail.

so don't bother, if someone wants your email blocked, they'll do it.

EDIT: i think i misunderstood your question...
yes, the only way to fix it is from the php script. you have to find that mail(); function
The from address specified in the headers like this:
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>
so you have to find where the from part is randomized and replace it with a fixed value...

hurricanebob
04-18-2007, 02:16 AM
I didn't realize it, but the php file containing the script was loaded on the server after all. Below is the contents of the current script. What/Where EXACTLY would I have to add to this script to make it work?

Note - Thanks to all for your speedy replies!

PHP Source Code:

<?php
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
$query_vars = $_GET;
} elseif ($request_method == "POST"){
$query_vars = $_POST;
}
reset($query_vars);
$t = date("U");
$file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
$fp = fopen($file,"w");
while (list ($key, $val) = each ($query_vars)) {
fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
fputs($fp,"$val\n");
fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
if ($key == "redirect") { $landing_page = $val;}
}
fclose($fp);
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}

?>

thetestingsite
04-18-2007, 02:20 AM
That script isn't even sending an email, but instead is writing a file just above your document root and in the folder "data" with the filename "gdform_{unixTimestamp}". This could be saving it as the email (if your server uses file-based emails), but as I said, the above script does not send any emails.

Hope this helps.

hurricanebob
04-18-2007, 02:32 AM
OK. I'll take your word for it (cause I really don't know one way or the other), but somehow the contents of the form gets sent to the email address specified.

Note - The email address is specified within the Go-Daddy control panel, it is not specified anywhere within the HTML of the page, or evidently not in the php code either. Hmmmm. What next?

Anybody have any other suggestions (perhaps using a different technology) to add a simple form to this site?

thetestingsite
04-18-2007, 02:43 AM
Well, instead of using the premade form from Go Daddy, why not make your own (or use another one). Here is one that I just made up that will work with the form you posted above.

Make a file named "mailer.php" and put this into it:


<?php

$to = "me@mydomain.com"; //change this to your email address
$from = "noreply@mydomain.com"; /* change this to the email address you want to "send" from */

//assign the variables
$subject = $_POST['subject'];
$redirect = $_POST['redirect'];
$name = $_POST['Name'];
$address = $_POST['Address'];
$city = $_POST['City'];
$state = $_POST['State'];
$zip = $_POST['Zip'];
$comments = $_POST['Comments'];
$email = $_POST['Email'];


$msg = <<<HERE
Name: $name

Email: $email

Address: $address
$city, $state $zip

Comments: $comments
HERE;

mail($to, $subject, $msg, 'From: PHP Script <'.$from.'>');

header('Location: '.$redirect);
?>



Simply point the form action to mailer.php (or whatever you name it) and that's it.

Hope this helps.

hurricanebob
04-18-2007, 04:26 AM
thetestingsite,

You da man!

That worked perfectly!

I was even able to flag messages from the form as "not spam", and they go right into my inbox.

I can't tell you how many hours I wasted trying to contact Go-Daddy, and experimenting with various options that didn't work at all.

Your solution nailed it, and I was able to get it all up and running in less than 5 minutes.

This has been, by far, the best experience I have ever had, using a technical forum. I appreciate all the prompt, helpful and accurate advice that has been given to me by everybody.

Thanks again,

HB

thetestingsite
04-18-2007, 04:29 AM
Not a problem at all, let us know if you need any more help.