Cooper94 Posted July 22, 2009 Share Posted July 22, 2009 <?php if(isset($_POST['email'])) { $firstname = $_POST['first_name']; $lastname = $_POST['last_name']; $email = $_POST['email']; $subject = $_POST['subject']; $comment = $_POST['comments']; $date = date("F j, Y, g:i a"); if(empty($firstname) || empty($email) || empty($comment)) { echo "<center><font color=red>Please Fill In All The Fields.<br></font></center>"; }else{ echo "<center><font color=red>Thank you for contacting us, we should get back to you within 24 hours.<br></font></center>"; } $to = "[email protected]"; $subject = "$subject"; $message = "Date: $date First Name: $firstname Last Name: $lastname Comments: $comment "; $headers = "From: ". $firstname . " <" . $email . ">\r\n"; ini_set("sendmail_from", $email); mail($to, $subject, $message, $headers); } ?> Problem is, is when I enter and actual email address it wont send but if I just put text with out the @ symbol it will send. I would love your input on what I did wrong, thank you. Link to comment https://forums.phpfreaks.com/topic/166927-php-mail/ Share on other sites More sharing options...
trq Posted July 22, 2009 Share Posted July 22, 2009 but if I just put text with out the @ symbol it will send How do you know its sending if the email isn't going to a valid email address? Makes no sense. Link to comment https://forums.phpfreaks.com/topic/166927-php-mail/#findComment-880122 Share on other sites More sharing options...
Coreye Posted July 22, 2009 Share Posted July 22, 2009 Your error checking doesn't work very well either. Even if they don't fill in all the fields, an email will still be sent. You need to include the mail() function into the if() part. Link to comment https://forums.phpfreaks.com/topic/166927-php-mail/#findComment-880124 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.