Php email from a form script- Please help!

software development


I’m having trouble with php email from a form scripts. I’ve tried many ones, including ones I purchased.

I’ve settled on this “simple” one for now (i’ld prefer to use FormToEmailPro ( but I’ve found that any script I use doesn’t always send emails and when it does, it doesn’t put all info in the email (just one or two items) even though when I error check (echo) it does define all the variables correctly. And yes, I check my spam folder. I’ve been using my personal gmail account for testing as I don’t have the password to the email they set up for the form to send messages to.

First Name:

Last Name:



Reason for contacting URSA?
Request more information Recommend a project Suggest a resource Get URSA to help a community


<?php $to = "" $subject = $_POST['subject']; $name = $_POST['nameFirst'].$_POST['nameLast']; $phone = $_POST['phone']; $email = $_POST['email']; $message = $_POST['messagebox']; if(isset($_POST['submit'])) { $body = "From: {$name}\n Phone: {$phone}\n E-Mail: {$email}\n Message:\n {$message}"; //$body .= wordwrap($body,70); $headers = "From: ". $name . " <" . $email . ">\r\n"; $headers .= "Reply-To:". $email ."\r\n"; mail($to, $subject, $body, $headers); // redirect header('Location: ThankYouContact.html'); //echo "$body"; } // Error Checking /* if (@mail($to, $subject, $message)) { //@ suppresses error msg echo('

Mail sent successfully.

'); } else { echo('

Mail could not be sent.

'); } */ // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?>

I’ld appreciate any help. I’ve been working on this for too long and really need this resolved. Thank you!


That is code that shouldn’t be used. Your site will be exploited in order to send spam/malware with it if you do.

Obvious probelm:

The value of the “From” header should be a DreamHost hosted e-mail address according to the spam prevention policy update.