mr_badger Posted May 29, 2007 Share Posted May 29, 2007 I have created a simple contact form, uploaded it to my server, tested it out and get the message that the email has been sent but it never arrives in my email inbox, probabaly really simple. This is the code for the contactsent.php <?php $name=$_POST['name']; $email=$_POST['email']; $message=$_POST['message']; $to="myemailaddress.com"; $message="Name: $name n E-mail: $email n Comments: $comments n"; if(mail($to,"Contact from Pure.Salon contact form",$message,"From: $emailn")) { echo "Thank you, your email has been sent."; } else { echo "Sorry but there is an error. Try again please."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53465-simple-contact-form-question/ Share on other sites More sharing options...
per1os Posted May 29, 2007 Share Posted May 29, 2007 if(mail($to,"Contact from Pure.Salon contact form",$message,"From: $email \r\n")) { Try that. Remember the mail function returning true/false on success does not necessarily mean it was succesful/unsuccesful. Quote Link to comment https://forums.phpfreaks.com/topic/53465-simple-contact-form-question/#findComment-264242 Share on other sites More sharing options...
gabeg Posted May 29, 2007 Share Posted May 29, 2007 FYI: \n is a newline, not simply n Quote Link to comment https://forums.phpfreaks.com/topic/53465-simple-contact-form-question/#findComment-264244 Share on other sites More sharing options...
Daniel0 Posted May 29, 2007 Share Posted May 29, 2007 <?php $to = "somebody@example.com"; $message = "Name: {$_POST['name']}\nE-mail: {$_POST['email']}\nComments: {$comments}\n"; // note that $comments is not initialized if(mail($to, "Contact from Pure.Salong contact form", $message, "From: {$_POST['email']}")) { echo "Thank you,your email has been sent."; } else { echo "Sorry but ere is an error. Try again please."; } ?> Are you doing this on localhost or a remote server? For the Mail functions to be available' date=' PHP must have access to the sendmail binary on your system during compile time.[/quote'] Chances are that you haven't got any sendmail binary - I haven't got that either on my localhost. About the code... why do you redeclare all the values? You can use arrays in strings... Quote Link to comment https://forums.phpfreaks.com/topic/53465-simple-contact-form-question/#findComment-264253 Share on other sites More sharing options...
mr_badger Posted May 30, 2007 Author Share Posted May 30, 2007 Thanks for the code but again this still does not work. The thing I cant work out is that I have the original code working on another website with the same hosting company and that works fine, but it wont work for this website. Quote Link to comment https://forums.phpfreaks.com/topic/53465-simple-contact-form-question/#findComment-264641 Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 Example 1074. Sending mail with an additional command line parameter. The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path. <?php mail('nobody@example.com', 'the subject', 'the message', null, '-fwebmaster@example.com'); ?> Have you tried the -f parameter ??? Some hosts require that for mail to be sent. Quote Link to comment https://forums.phpfreaks.com/topic/53465-simple-contact-form-question/#findComment-264766 Share on other sites More sharing options...
Daniel0 Posted May 30, 2007 Share Posted May 30, 2007 Thanks for the code but again this still does not work. The thing I cant work out is that I have the original code working on another website with the same hosting company and that works fine, but it wont work for this website. Guess you have to talk with your host then... Quote Link to comment https://forums.phpfreaks.com/topic/53465-simple-contact-form-question/#findComment-265019 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.