Log in

View Full Version : Changing Recipient in Godaddy PHP Form



wacka2
11-01-2007, 08:21 PM
Hi, I'm new to this forum and to PHP. I've been scouring the net for a couple of days hoping to find my answer but without luck.

I host a few websites under one main account at godaddy.com. I'd like to be able to have each website have its own formmail and have the results be sent to different recipients. In order to do this, godaddy suggested using PHP. Otherwise, all results get sent to one email address that you set under preferences.

I've been able to get the form to work beautifully on one of my subaccounts but I'm having a hell of a time trying to figure out where to specify the email address. I thought I could add this to the existing gdform.php (which I've renamed mailer.php):

$to = "myemail@gmail.com";
$subject = "Form";

...but the email still gets delivered to the main address. Here's the original gdform.php:

<?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"]."/");
}


?>

Godaddy's only instructions for me were to 1) put the .php file in the root folder of the subaccounts and 2) make sure I specify their relay server in a custom script. I've found this server information in a .ini file. Which file do I alter and where should the code be inserted?

Any kind of help would be greatly, greatly appreciated!

blm126
11-01-2007, 11:15 PM
A quick overview says it can't be done. I would need to see the contents of $_POST to be sure, but what it looks like godaddy is doing is sending the email data to another script they control. The modifications have to be made on their end not yours.

djr33
11-01-2007, 11:39 PM
Check the settings in cpanel, or move on from GD's prewritten scripts. I'm hosted there and I don't use 'em... more trouble than they're worth.

I would assume that the form is setup to automatically email YOU, ie the owner of the account with the email they have on record.

wacka2
11-02-2007, 02:08 AM
Thanks for the replies. djr33, are you saying it CAN be done because blm126 says the opposite. If so, could you be a little more specific. Yes, I am an annoying newbie but how else will I learn?

djr33
11-02-2007, 08:24 AM
Oh, I'm sure it can be done; however, I don't see anything, as he said, that will allow it in that script. It doesn't send the mail; it adds it to a queue that will then be sent later, in some undetermined way. I think cpanel may hold the key to it, so you can set the "receiving email"... if not, no real clue. It may not be possible if this relies on something you don't have permission to change on the server; I don't know.

As I said, may just be best to find one that you have full control over.