PHP mail issue (Please Help)

I am a designer, and I have a flash portfolio site with a contact section on it. It uses a simple button to post:

on (release) {
form.loadVariables(“email.php”, “POST”);
(the variables within the “form” element are name, email, and message)

The script in the php page is as follows:

<?php $sendTo = ""; $subject = "Comment from my flash site"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = $_POST["message"]; mail($sendTo, $subject, $message, $headers); ?>

This script works, or it did on my old servers. I just switched to Dreamhost. I still get an email in my inbox, from to me but the subject, message, and reply-to are all blank. Am I missing something or does the code have errors?

Did you try printing (echoing) those variables to the screen ( as a debugging step executed before the send email routine) to make sure the variable are properly populated?


no. my PHP experience is small at the time. What would I need to do to accomplish this?

One thing I see right off the bat is don’t place a period in between double quotes. php will assume you are trying to merge strings together. If you want a literal period you need to use single quotes.
so your sento string would be:
$sendTo = ‘’;
to view this string it would be
print $sendTo;
or better yet use:
print '$sendTo= ’ . $sendTo;
See how the period merged the two strings together.
Anything between single quotes is taken literally and anything between double quotes will get processed.
Hope this helps,

My website

Instead of print you can also use echo.

My website

To “echo” in the context I was using it, just means to print (using the echo or print function) the variables to the screen so you can check to see if the contents are as you expected. This is a common debugging technique, and can help you identify problems in the assignment of values to your variables.

Information on the print and echo functions can be found in the PHP manual (check here for “print” and check here for “echo”).
Note: Normally I would link you to , but it is not responding to requests as I type this. The manual is the same on both sites, though there are more “comments” on the site).

Essentially, you can display the contents of a variable at various stages in your program by inserting these functions into your code at various places:

print $variable; or
echo $variable;

just put one of these into your code where you want to determine the contents of the variable, and as the code runs, you will be able to see what the variable holds at that point in the program’s execution. Once you are satisfied the values are as expected, you can just delete them. If you find the variables do not contain what you expect, you can work on your code until they do, using these “check” outputs to verify how your code is impacting the variables.


I know nothing about Flash, or how you’re submitting the info, but you could try this slightly cleaner code and see if it helps. If it still doesn’t work, at least it will look pretty. :wink:

Also note the double linefeed I added after the last header. Probably not your problem, but it helps avoid header-injection.

$sendTo = ‘’;
$subject = ‘Comment from my flash site’;
$headers = “From: {$_POST[‘firstName’]} {$_POST[‘lastname’]} <{$_POST[‘email’]}>\r\n”;
$headers .= “Reply-To: {$_POST[‘email’]}\r\n”;
$headers .= “Return-path: {$_POST[‘email’]}\r\n\r\n”;
$message = $_POST[‘message’];

mail($sendTo, $subject, $message, $headers);

:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.

Ha! I hovered over your links, and before even getting to the next sentence, I was already thinking, “Why isn’t he using links??”


Then for the first time ever, I got to see not load for me. I can ping it… just can’t see it.

:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.

Yep! I thought it would be “poor” to refer him to links that he couldn’t visit. I had never seen not responding before either. Since that post, it has responded with pages “every now and then” for me, but is not responding again now. I can ping it too, but no pages will load :open_mouth: .


Thanks everyone! I managed to get it working. I appreciate the help big time.

Just tried php’s site and it seams to be working at the moment.

My website