mail won't thanks

This form loads nicely and takes all the info. The ‘thank you’ message appears after I hit send. The form is never actually emailed, though. Any help is appreciated.

here is the mail form, the form that gets the info to mail:


mail form Please tell us a little about yourself and your vehicle

Your First Name: Last Name
Email Address: Mobile Phone:


2013 2012 2011 2010 2009 2008 2007 2006 2005 2004 2003 2002 2001 Other

Trim Level


Is it 4x4 or AWD?

Please check if this vehicle has:
Leather seats? Power moonroof?
DVD player? Full crew cab?
Extended cab?

Tell us a little about the vehicle:


here is the sendmail form:


Send the email <?php

//start building the mail string

$msg = “First Name “.$_POST[“firstname”].”\n”;
$msg = “Last Name “.$_POST[“lastname”].”\n”;
$msg = “Email Address “.$_POST[“email”].”\n”;
$msg = “Phone Number “.$_POST[“phone”].”\n”;
$msg = “year “.$_POST[“year”].”\n”;
$msg = “manufacturer “.$_POST[“manufacturer”].”\n”;
$msg = “model “.$_POST[“model”].”\n”;
$msg = “trim “.$_POST[“trim”].”\n”;
$msg = “miles “.$_POST[“miles”].”\n”;
$msg = “4x4 “.$_POST[“4x4”].”\n”;
$msg = “leather “.$_POST[“leather”].”\n”;
$msg = “moonroof “.$_POST[“moonroof”].”\n”;
$msg = “dvd “.$_POST[“dvd”].”\n”;
$msg = “crewcab “.$_POST[“crewcab”].”\n”;
$msg = “description “.$_POST[“description”].”\n”;

$formcontent=" From: $firstname \n Last Name: $lastname \n Phone: $phone \n year: $year \n Manufacturer: $manufacturer \n Email: $email \n miles: $miles \n model: $model \n Message: $message 4x4: $4x4 \n leather: $leather \n moonroof: $moonroof \n dvd: $dvd \n crewcab: $crewcab \n Description: $description \n";

$recipient = "[email protected]";
$subject = “Subject goes here”;
$mailheader = “From: $email \r\n”;
mail($recipient, $subject, $formcontent, $mailheader) or die(“Error!”);

echo “Thank you for your inquiry.”;


Are you running this off linux or windows?

Linux, cpanel.

I can make a form work with about four parts…name, address, email and phone…for example. But when I add the radio buttons and the drop down parts, it won’t email. I’m willing to change the form some if I can make it work and somehow still capture the basic car description. Thx

I’m having trouble understanding your code.

[php]$msg = “First Name “.$_POST[“firstname”].”\n”;
$msg = “Last Name “.$_POST[“lastname”].”\n”;[/php]
Do you intend to append all the data here? As written each line will overwrite the previous line. Also you assume that all array keys are available. The way posting a form works is that empty fields aren’t submitted at all. So if you don’t check every box/fill every field you are going to get errors. Do you have error reporting on?

[php]$formcontent=" From: $firstname \n Last Name: $lastname [/php]
This won’t work, you don’t have $firstname, $lastname, etc defined.

[php]$mailheader = “From: $email \r\n”;[/php]
This won’t work for the same reason as above.

My suggestion:

Send the email <?php

$emptyText = ‘Not submitted’;

$form = array(
‘firstname’ => !empty($_POST[“firstname”]) ? $_POST[“firstname”] : $emptyText,
‘lastname’ => !empty($_POST[“lastname”]) ? $_POST[“lastname”] : $emptyText,
‘email’ => !empty($_POST[“email”]) ? $_POST[“email”] : $emptyText,
‘phone’ => !empty($_POST[“phone”]) ? $_POST[“phone”] : $emptyText,
‘year’ => !empty($_POST[“year”]) ? $_POST[“year”] : $emptyText,
‘manufacturer’ => !empty($_POST[“manufacturer”]) ? $_POST[“manufacturer”] : $emptyText,
‘model’ => !empty($_POST[“model”]) ? $_POST[“model”] : $emptyText,
‘trim’ => !empty($_POST[“trim”]) ? $_POST[“trim”] : $emptyText,
‘miles’ => !empty($_POST[“miles”]) ? $_POST[“miles”] : $emptyText,
‘4x4’ => !empty($_POST[“4x4”]) ? $_POST[“4x4”] : $emptyText,
‘leather’ => !empty($_POST[“leather”]) ? $_POST[“leather”] : $emptyText,
‘moonroof’ => !empty($_POST[“moonroof”]) ? $_POST[“moonroof”] : $emptyText,
‘dvd’ => !empty($_POST[“dvd”]) ? $_POST[“dvd”] : $emptyText,
‘crewcab’ => !empty($_POST[“crewcab”]) ? $_POST[“crewcab”] : $emptyText,
‘description’ => !empty($_POST[“description”]) ? $_POST[“description”] : $emptyText

//start building the mail string

$msg = "First Name: " . $form[‘firstname’] . “\n”;
$msg .= "Last Name: " . $form[‘lastname’] . “\n”;
$msg .= "Email Address: " . $form[‘email’] . “\n”;
$msg .= "Phone Number: " . $form[‘phone’] . “\n”;
$msg .= "year: " . $form[‘year’] . “\n”;
$msg .= "manufacturer: " . $form[‘manufacturer’] . “\n”;
$msg .= "model: " . $form[‘model’] . “\n”;
$msg .= "trim: " . $form[‘trim’] . “\n”;
$msg .= "miles: " . $form[‘miles’] . “\n”;
$msg .= "4x4: " . $form[‘4x4’] . “\n”;
$msg .= "leather: " . $form[‘leather’] . “\n”;
$msg .= "moonroof: " . $form[‘moonroof’] . “\n”;
$msg .= "dvd: " . $form[‘dvd’] . “\n”;
$msg .= "crewcab: " . $form[‘crewcab’] . “\n”;
$msg .= "description: " . $form[‘description’];

$recipient = "[email protected]";
$subject = “Subject goes here”;
$mailheader = "From: " . $form[‘email’] . “\r\n”;
mail($recipient, $subject, $msg, $mailheader) or die(“Error!”);

echo “Thank you for your inquiry.”;


I’d also suggest considering changing to use phpmailer/swiftmailer/something else than the mail function. For one mail only returns a bool so if you end up getting “Error!” you don’t know why…

You radio buttons are constructed wrong which might be your issue.

[php] Yes

Should be something like this.

[php] Yes

Thanks Jim. That fixed it. Thanks to everyone else who tried to help me also. I appreciate it.

Sponsor our Newsletter | Privacy Policy | Terms of Service