ROCKSTAR Posted February 27, 2008 Share Posted February 27, 2008 Hey guys, I'm trying to send mail through a form, I've followed a number of tutorials and it seems as if the code is correct, it doesnt error but I don't get any mail through.. the code for my sendmail.php is below - any pointers would be great. <? $name=$_POST['name']; $email=$_POST['email']; $comment=$_POST['comments']; $to="me@mydomain.co.uk"; mail($to, "Message from my PHP page", $comment, $email); ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 27, 2008 Share Posted February 27, 2008 The 4th argument needs to be a header. Something like this should work: <?php $name=$_POST['name']; $email=$_POST['email']; $comment=$_POST['comments']; $to="me@mydomain.co.uk"; $subject = "Message from my PHP page"; $headers = "From: $email\r\n"; mail($to, $subject, $comment, $headers) or die("Couldn't send mail"); ?> Quote Link to comment Share on other sites More sharing options...
freenity Posted February 27, 2008 Share Posted February 27, 2008 if you are sending the email to a hotmail box, the problem might be in headers. Check this: http://gwphp.feudal-times.net/?p=4 it's a function that sends email fine... and tested. Quote Link to comment Share on other sites More sharing options...
ROCKSTAR Posted February 27, 2008 Author Share Posted February 27, 2008 Thanks to the quick replies guys... I'm still getting 100% performance and 0% results though - think perhaps its something on the server causing a problem. Thanks again for the help - if the solution turns out to be freakish I'll post my findings. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 27, 2008 Share Posted February 27, 2008 Another problem that is becoming more common is a hosting service blocking mail with a FROM header that is outside the domain. Trying using a FROM header with an email address from your domain. So, let's forget out the POST for now, and just get email working. Assuming your domain is 'mydomain.co.uk', try this: <?php $to="me@mydomain.co.uk"; $from="info@mydomain.co.uk"; $subject = "Message from my PHP page"; $comment = "My message goes here"; mail($to, $subject, $comment, "From: $email") or die("Couldn't send mail"); print "Email Sent"; ?> Also, if you have a spam filter make sure you check that. Quote Link to comment Share on other sites More sharing options...
ROCKSTAR Posted February 28, 2008 Author Share Posted February 28, 2008 Thanks rhodesa, I'll give it a try and let you know the results... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.