thefollower Posted December 1, 2007 Share Posted December 1, 2007 I am wondering what this error means this is my first attempt at email...is there something i have not done in my settings? Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\test4.php on line 7 Message delivery failed... <?php include("include.php"); $to = "test@gmail.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>"); } ?> Quote Link to comment Share on other sites More sharing options...
Locked Posted December 1, 2007 Share Posted December 1, 2007 The mail function does not work on windows (Or it dident used to, double check) Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 1, 2007 Author Share Posted December 1, 2007 What is the new function for it ? Quote Link to comment Share on other sites More sharing options...
Locked Posted December 1, 2007 Share Posted December 1, 2007 http://uk2.php.net/mail It looks like it does support windows but you need to provide exta info. Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 1, 2007 Author Share Posted December 1, 2007 Damn confusd again lol just when i thought i worked it out Quote Link to comment Share on other sites More sharing options...
sowmithrii Posted December 1, 2007 Share Posted December 1, 2007 In your code..below there is a small error. mail() function takes four parameters 1. to 2. subject 3. message 4. headers for ex:- mail("test@gmail.com", "This is the subject", "Here will be your message", "From: sender@gmail.com"); just execute the above function by giving a working email address in the place of test@gmail.com, it doesnt matter from whom u r getting the mail and what is in the headers section (i.e .. sender@gmail.com) ('From:' should always be there as the fourth parameter. you can add more information to this parameter.. but for u the above function works fine) and thats what the error message saying , lacking of the fourth parameter. -------------------------------------got cleared ? <?php include("include.php"); $to = "test@gmail.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>"); } ?> Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 1, 2007 Author Share Posted December 1, 2007 I did put a legit email i just changed it to test@gmail.com cos i did not want to put my email out in public.. <?php include("include.php"); $to = "test@gmail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $From = "sender@gmail.com"; if (mail($to, $subject, $body, $From)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Is that how it should be? Stil gives me error even though i put the sender in... Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\test4.php on line 8 Message delivery failed... Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 1, 2007 Author Share Posted December 1, 2007 bumpy Quote Link to comment Share on other sites More sharing options...
revraz Posted December 1, 2007 Share Posted December 1, 2007 You don't have Mail enabled in your PHP.INI, just like the error states. Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 1, 2007 Author Share Posted December 1, 2007 How do i turn it on last time i fiddled with settings i totally screwed up my apache and had to re-install.. don't want to make same mistake twice. I found this in my settings: sendmail_from no value no value sendmail_path no value no value Though theres no option to just turn it on in apache :S Quote Link to comment Share on other sites More sharing options...
revraz Posted December 1, 2007 Share Posted December 1, 2007 Try this mail($to, $subject, $body, "From: <$From>"); Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 1, 2007 Author Share Posted December 1, 2007 Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\test4.php on line 8 Message delivery failed... This is what i have: <?php include("include.php"); $to = "test@gmail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $From = "sender@gmail.com"; if (mail($to, $subject, $body, "From: <$From>")) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted December 1, 2007 Share Posted December 1, 2007 Do you have a mailserver? Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 1, 2007 Author Share Posted December 1, 2007 Well i got Xampp which came with mercury mail which im presuming was a mail server for testing on localhost? Quote Link to comment Share on other sites More sharing options...
sowmithrii Posted December 2, 2007 Share Posted December 2, 2007 see man, let me explain u clearly.. with the xampp u have installed u will get the apache server, sql server and some other but not mail server. if the code u have given is correct, even if u r working locally(means on your local machine , not on a web hoster) u wont get any errors. if there are any errors then it will show u them.(even if u r working on web server) the mistake in your code as i have explained earlier is missing last parameter ur code after modified. <?php include("include.php"); $to = "test@gmail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $From = "From: sender@gmail.com"; //(this is how this line should be.. try this but not on your local machine if (mail($to, $subject, $body, $From)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> you do one thing. login to www.x10hosting.com and create a login id. then he will give u a site name.. for ex. www.yourname.x10hosting.com then go to your cpanel (http://yourname.x10hosting.com:2082) probably looks like this.. this cpanel link will be sent to u in your mail.. there u can upload your php pages (this is all free of cost.. thats a free site for web hosting) there upload a file index.php and write your code in that file. then access your site with www.yourname.x10hosting.com now if mail has been sent u will see success msg and if failed , your failure message. you can get the status of your mail function..whether its successfull or failure. by assigning your mail function to a variable. $ok = mail($to, $subject, $body, $From); $ok will be TRUE if success, FALSE if failure. hope this helped u. Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 2, 2007 Author Share Posted December 2, 2007 see man, let me explain u clearly.. with the xampp u have installed u will get the apache server, sql server and some other but not mail server. if the code u have given is correct, even if u r working locally(means on your local machine , not on a web hoster) u wont get any errors. if there are any errors then it will show u them.(even if u r working on web server) the mistake in your code as i have explained earlier is missing last parameter ur code after modified. <?php include("include.php"); $to = "test@gmail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $From = "From: sender@gmail.com"; //(this is how this line should be.. try this but not on your local machine if (mail($to, $subject, $body, $From)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> you do one thing. login to www.x10hosting.com and create a login id. then he will give u a site name.. for ex. www.yourname.x10hosting.com then go to your cpanel (http://yourname.x10hosting.com:2082) probably looks like this.. this cpanel link will be sent to u in your mail.. there u can upload your php pages (this is all free of cost.. thats a free site for web hosting) there upload a file index.php and write your code in that file. then access your site with www.yourname.x10hosting.com now if mail has been sent u will see success msg and if failed , your failure message. you can get the status of your mail function..whether its successfull or failure. by assigning your mail function to a variable. $ok = mail($to, $subject, $body, $From); $ok will be TRUE if success, FALSE if failure. hope this helped u. I did put $From ... see above. How ever i did not know i needed a server for it. i thought it would work from localhost like everything else. I'll sign up to that site and try it out. Will let you know. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 2, 2007 Share Posted December 2, 2007 It doesn't matter if the From: is in the Variable or in the mail () function, as long as it's there. The problem is you don't have a mail server. Quote Link to comment Share on other sites More sharing options...
sowmithrii Posted December 2, 2007 Share Posted December 2, 2007 hei, the follower... u have added $From to your code..but see that state ment carefully u have given like this $from = "xyz@abc.com"; but it should be like this $from = "from: xyz@abc.com"; this is becos, fourth parameter to mail function is not just the from parameter.. it contains more details like from: "xyz@abc.com"; to: "x@y.com" mime: 1.0 and so... the above all parameters combinely constitute the last parameter. its called headers. u might have observed in your mail.. the details of the person who sent that mail, to whom., text type(html/plain)... and so.. these details are the $headers(the fourth parameter) anyhow read the replies carefully.. even a dot in the place of coma will affect the code. 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.