Jump to content

PHP formmail help


kanala

Recommended Posts

What's wrong with this? When I post it, it redirects to the success page, but I don't receive any emails.This is the form

<form name="email" action="formmail.php" method="post"><input type="hidden" name="subject" value="Contact us"><input type="hidden" name="redirect" value="redirect.php"><input type="text" name="FullName" size="30"><input type="text" name="Email" size="30"><input type="text" name="OrderID" size="30"><textarea name="Question" cols="30" rows="8"></textarea><input type="submit" value="Submit"></form>
This is formmail.php
<?php$from = "From: ****email address****;$to = "****email address****";$subject = "Default subject";if (isset($_POST['subject'])){ $subject = $_POST['subject']; unset($_POST['subject']);}if (isset($_POST['redirect'])){ $redirect = $_POST['redirect']; unset($_POST['redirect']);}$body = "An online message has been received on {$_SERVER['HTTP_HOST']}";if ($_SERVER['HTTP_REFERER'] != "")$body .= " from {$_SERVER['HTTP_REFERER']}";$body .= "\n\n";foreach ($_POST as $key => $val){ $body .= "{$key}: {$val}\n";}$body = wordwrap($body, 70);if(mail($to,$subject,$body,$from)){$redirect = $redirect."?sent=1";header("location:{$redirect}");}else{$redirect = $redirect."?sent=0";header("location:{$redirect}");}?>
Link to comment
Share on other sites

It redirects to the same page with a different querystring value. Print the values you are sending to the mail function and make sure they are correct. If you're sending this to a free email address like hotmail or yahoo the message will probably end up in your junk folder.

Link to comment
Share on other sites

It redirects to the same page with a different querystring value. Print the values you are sending to the mail function and make sure they are correct. If you're sending this to a free email address like hotmail or yahoo the message will probably end up in your junk folder.
Sorry I'm not very good at PHP, how would I print the values?
Link to comment
Share on other sites

The 4 things you're sending to the mail function:if(mail($to,$subject,$body,$from))
It shows everything that it should, my email (to), the email content, from email and subject.
Link to comment
Share on other sites

Then the email should at least be getting delivered to the mail transfer agent (there's no guarantee it left the server). Make sure to check your junk email folders, and make sure that you are running this on a server that has an SMTP server set up. If you're running this on a home test machine it's probably not going to work.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...