# I need PHP help Please



## Shodan99 (Sep 24, 2009)

My webmail isn't working right. I built a small php file for the sole purpose of accepting customer comments on my website instead of using html mailto: command. I'm trying to set it up so that my customers do not need to set up a pop3 or imap client to send me mail.

but i am lost. somehow my emails are not getting to me. i used the following commands, Please Help:

<?php
$first_name= $_POST['first_name'];
$last_name= $_POST['last_name'];
$address1= $_POST['address1'];
$city= $_POST['city'];
$state= $_POST['state'];
$zip= $_POST['zip'];
$email= $_POST['email'];
$phone= $_POST['phone'];
$category= $_POST['category'];
$request_category= $_POST['request_category'];
$request= $_POST['request'];
$message= $_POST['message'];

$headers= 'From: andrew@tampabaywebmaster.com' . "\r\n" .
    'Reply-To: andrew@tampabaywebmaster.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

$body = "
First Name: $first_name
Last Name: $last_name
Address:
$address1
$city
$state
$zip

Email: $email
Phone: $phone
Fax: $fax
Request Category: $request_category
Additional Info: $request
$message
";

if (!isset($email) || !isset($first_name)) {
header("Location: http://www.tampabaywebmaster.com/pages/error.html ");
}
elseif (empty($email) || empty($first_name)) {
header("Location: http://www.tampabaywebmaster.com/pages/error.html ");
}
else {
mail("andrew@tampabaywebmaster.com","From: $first_name $last_name",$body,$headers,"-fandrew@tampabaywebmaster.com");
header("Location: http://www.tampabaywebmaster.com/pages/thankyou.html ");
}
?>


----------



## Disparia (Sep 25, 2009)

Code looks good, probably has to do with the mail configuration and/or site configuration. Is it shared, dedicated, or other hosting?


----------



## Shodan99 (Sep 26, 2009)

I'm using several hosting sites for several different websites. Godaddy, Justhost, Fatcow, and a few others, I am having the most problems with the accounts that are on Godaddy, Justhost I've got working now with that script but Godaddy is still giving me error messages.


----------



## Kreij (Sep 26, 2009)

What error message(s) are you getting when you run it on GoDaddy?
I'm not too versed in PhP, but I do know that the more information you provide, the better chance of someone being able to get it working for you.


----------



## Shodan99 (Sep 26, 2009)

I was getting a 404 error code


----------



## Oliver_FF (Sep 27, 2009)

can email addresses start with a - ?

"-fandrew@tampabaywebmaster.com"


----------



## FordGT90Concept (Sep 27, 2009)

I doubt it.  Looks to me like it was supposed to be:

-f "andrew@tampabaywebmaster.com"

...like a commandline variable or something.


Edit: Indeed...

http://www.computerhope.com/unix/usendmai.htm

-f name = Sets the name of the "from" person (that is, the sender of the mail).


----------



## Shodan99 (Sep 27, 2009)

Thanks guys, its working now.


----------

