email script

I’m learning php and have been working on an email script for my website.
I had this email script working, but now suddenly it stopped. Can you see what I may have done wrong?

Thanks,
Weird

[php]

<?php $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; if(isset($email) && isset($subject) && isset($message)) echo sendemail($email, $subject, $message); else{ echo ""; } function sendemail($email, $subject, $message){ $email = $email; $subject = $subject; $message = $message; global $error, $sucess; if(empty($email) || $email == "email" || !filter_var($email, FILTER_VALIDATE_EMAIL)) $error = "Check email field!"; elseif(empty($subject) || $subject == "subject") $error = "Check subject field!"; elseif(empty($message)) $error = "Please add message!"; else{ $to = "[email protected]"; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $message = wordwrap($message, 70); $headers = "From: $email"; mail($to,$subject,$message,$headers); $sucess = "Message has been recieved"; } } ?>

[/php]

well it looks like you got to and from backwards on the bottom part of the script, you are sending to fake at email .com and using the post data as the from address. so it will always mail to fake at email .com and just change who it is from.

Thanks for the quick reply.

The user inputs their email, subject and message and I have it set up to email me "[email protected]" (not my real email) and adds a from header to the email using the email they put into the form.

I think that is the right way to do it?

Anything else you notice?

Thanks

Another strange issue. I tried changing the $to variable to a different email address and it sent instantly. Why won’t it send to my (hotmail) account. It was working before.

Sponsor our Newsletter | Privacy Policy | Terms of Service