kanala Posted March 18, 2008 Share Posted March 18, 2008 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 More sharing options...
justsomeguy Posted March 18, 2008 Share Posted March 18, 2008 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 More sharing options...
kanala Posted March 18, 2008 Author Share Posted March 18, 2008 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 More sharing options...
justsomeguy Posted March 18, 2008 Share Posted March 18, 2008 With either a print or echo statement.http://www.php.net/manual/en/function.echo.php Link to comment Share on other sites More sharing options...
kanala Posted March 18, 2008 Author Share Posted March 18, 2008 With either a print or echo statement.http://www.php.net/manual/en/function.echo.php Which value would I echo?$body $subject etc? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 18, 2008 Share Posted March 18, 2008 The 4 things you're sending to the mail function:if(mail($to,$subject,$body,$from)) Link to comment Share on other sites More sharing options...
kanala Posted March 18, 2008 Author Share Posted March 18, 2008 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 More sharing options...
justsomeguy Posted March 18, 2008 Share Posted March 18, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.