mason20034 Posted August 29, 2006 Share Posted August 29, 2006 hi this is the first php i have written but i am having trouble getting it to work, server supports php, and it runs fine the email just isnt getting recived. any ideas.<?php if(isset($_POST['submit'])) { $to = "mason-@hotmail.com"; $subject = "Form"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message"; echo "Data has been submitted to $to!"; mail($to, $subject, $body); } else { echo "blarg!"; } ?> Quote Link to comment Share on other sites More sharing options...
Iceman512 Posted August 29, 2006 Share Posted August 29, 2006 Hey Mason20034,Don't know if this helps, but take a look here: http://webworld.simplythebest.net/node/35 Hope it works for you,Regards, Iceman Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 29, 2006 Share Posted August 29, 2006 [quote author=mason20034 link=topic=106066.msg423888#msg423888 date=1156852726]hi this is the first php i have written but i am having trouble getting it to work, server supports php, and it runs fine the email just isnt getting recived. any ideas.<?php if(isset($_POST['submit'])) { $to = "mason-@hotmail.com"; $subject = "Form"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message"; echo "Data has been submitted to $to!"; mail($to, $subject, $body); } else { echo "blarg!"; } ?> [/quote]there are a couple issues with your syntax within your mail() function. let's clean things up a bit, and let me know if it's still not coming through:[code]<?phpif(isset($_POST['submit'])) { $to = "mason-@hotmail.com"; $subject = "Form"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $headers = "From: $name_field <$email_field>\r\nReply-To: $email_field"; echo "Data has been submitted to $to!"; if (!mail($to, $subject, $body)) echo "blarg!"; else echo "Data has been submitted to $to!"; } ?>[/code]hope this helps Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted August 29, 2006 Share Posted August 29, 2006 The body of the message should contain just the message, not the headers. Put the headers in a separate variable:[code]<?phpif(isset($_POST['submit'])) {$to = "mason-@hotmail.com";$subject = "Form";$name_field = $_POST['name'];$email_field = $_POST['email'];$message = stripslashes($_POST['message']); $headers = "From: $name_field\n E-Mail: $email_field\n"; echo "Data has been submitted to $to!";mail($to, $subject, $message, $headers);} else {echo "blarg!";}?>[/code]Also, getting email to be recieved at Hotmail can be a challenge. There have been a number of threads in the past few weeks relating to it. Search this group to find them.Ken Quote Link to comment Share on other sites More sharing options...
mason20034 Posted August 29, 2006 Author Share Posted August 29, 2006 no nottings working tried several scripts on sevral web hosts. begining to think php is not for me.not using hotmail just used that address as i dint not want to give out my email address. i am using ntlworld and outlook Quote Link to comment Share on other sites More sharing options...
SharkBait Posted August 29, 2006 Share Posted August 29, 2006 How is it not working? Is it giving you an error?If the webserver has successfuly sent the mail, and you're sending it to Hotmail/Yahoo/Gmail there might be issues with either the content of the email and being caught as spam. Or the email is being redirected and most anti-spam software sees Relaying as a security issue. Quote Link to comment Share on other sites More sharing options...
mason20034 Posted August 29, 2006 Author Share Posted August 29, 2006 its showing the data has been submited to message. and ive checked my junk email box but there is noting there i cant understand it at all Quote Link to comment Share on other sites More sharing options...
SharkBait Posted August 29, 2006 Share Posted August 29, 2006 Are you using hotmail? Hotmail Live? If so I know I had to add the domain the mail was coming from into the trusted recipients list. Quote Link to comment Share on other sites More sharing options...
mason20034 Posted August 29, 2006 Author Share Posted August 29, 2006 no im using outlook and a ntlworld email address. im using it on a free web hosting account for testing puroposesthe address is http://mailmev1.awardspace.com/mail.htm Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 29, 2006 Share Posted August 29, 2006 [quote author=mason20034 link=topic=106066.msg424095#msg424095 date=1156868431]no im using outlook and a ntlworld email address. im using it on a free web hosting account for testing puroposesthe address is http://mailmev1.awardspace.com/mail.htm[/quote]one thing: the way you have your check written in your first post, it will ALWAYS appear that your mail was sent properly. check my first post above and try sending it that way. are you still getting the message that it was sent correctly? Quote Link to comment Share on other sites More sharing options...
mason20034 Posted August 29, 2006 Author Share Posted August 29, 2006 yes twice Quote Link to comment Share on other sites More sharing options...
mason20034 Posted August 29, 2006 Author Share Posted August 29, 2006 ive got to go on holiday for a week now. thanks to everyone who has helped me. if anyone comes up with a solution please post and i will tell you if it has been sucessfull in a weeks time. cheers all, james 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.