Sending form data with PHP mail() function

I’m trying to email form data using the PHP mail() function. The problem is that I’m not receiving any emails although I get a message stating the data was successfully sent. Does anyone see any problems with me code?

<?php // Pick up the form data and assign it to variables $fname_field = $_POST['first_name']; $lname_field = $_POST['last_name']; $address_field = $_POST['address']; $city_field = $_POST['city']; $state_field = $_POST['state']; $zip_field = $_POST['zip']; $phone_field = $_POST['phone']; $email_field = $_POST['email']; $resume_field = $_POST['resume']; // Build the email $to = "[email protected]"; $subject = "B&A Resume Customer"; $message = "FirstName: $fname_fieldn LastName: $lname_fieldn Address: $address_fieldn City: $city_fieldn State: $state_fieldn Zip: $zip_fieldn Phone: $phone_fieldn Email: $email_fieldn Resume: $resume_field"; $headers = "From: $email_field"; // Send the mail using PHPs mail() function mail($to, $subject, $message, $headers); // Redirect header("Location: success.html"); ?>

Probably you have the problems with the mail server. Sometimes that can happen because of the headers. Try to send just mail([email protected]’, '‘Test’, ‘Test’); You can also try to add n to the headers.

Or try testing whether or not the mail was sent by using the return value of mail().

Sponsor our Newsletter | Privacy Policy | Terms of Service