Eskimo Posted December 14, 2006 Share Posted December 14, 2006 I'm trying to put the php function mail() into my website but it seems to not be working.I have put a condition on it to test, and it keeps failing, which leads me to believe its my code, or the server I'm running it on.The code is thus:[code]<?php$to = "my@email.com";$subject = "Hi!";$body = "Hi,\n\nHow are you?";if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); }?>[/code]That's all that exists in the script. Whenever I run it, I get a Message delivery failed error.Is there anything wrong with the code? And, if not, what can be done to make this work?Thanks all. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted December 14, 2006 Share Posted December 14, 2006 make sure error reporting is turned on and that error reporting is set to E_ALL.[code]ini_set("display_errors", 1);ini_set("error_reporting", "E_ALL");[/code] Quote Link to comment Share on other sites More sharing options...
Eskimo Posted December 14, 2006 Author Share Posted December 14, 2006 How do I turn error reporting on and set to E_ALL? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted December 14, 2006 Share Posted December 14, 2006 [quote author=hitman6003 link=topic=118536.msg484444#msg484444 date=1166058328][code]ini_set("display_errors", 1);ini_set("error_reporting", "E_ALL");[/code][/quote] Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 14, 2006 Share Posted December 14, 2006 you have to paste that at the top of your script, just so you no. :)(paste what hitman6003 posted). :P Quote Link to comment Share on other sites More sharing options...
Eskimo Posted December 14, 2006 Author Share Posted December 14, 2006 That doesn't do anything. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 14, 2006 Share Posted December 14, 2006 it may be your server or port then. not sure if it makes a difference but remove the if statement so you just have the variables and the mail function there. Quote Link to comment Share on other sites More sharing options...
Eskimo Posted December 14, 2006 Author Share Posted December 14, 2006 I have tested this using two different hosting services. Using the exact same scipt on each. It works on one, but doesn't on the other.Is there anything that needs to be enabled for it to work? Quote Link to comment Share on other sites More sharing options...
mjlogan Posted December 14, 2006 Share Posted December 14, 2006 [code]<?phperror_reporting(E_ALL);$to = "my@email.com";$subject = "Hi!";$body = "Hi,\n\nHow are you?";mail($to, $subject, $body);?>[/code]paste the following in a file and load it, that will output an error and someone might actually be able to help you then..... 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.