Jaswinder Posted May 18, 2013 Share Posted May 18, 2013 feed.php <form action="feed1.php" method="post">Name - <input type="text" name="name" /><br /><br />Email - <input type="text" name="email" /><br /><br />Subject - <input type="text" name="subject"/><br /><br />message - <textarea rows="5" cols="10" name="message"></textarea><br /><br /><input type="submit" value="Send mail" name="sub" /></form> feed1.php <?phpextract($_POST);$to="sehgal_jas@yahoo.com";$headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$headers.="From:$name<$email>";mail($to,$subject,$msg,$headers);echo "Message sent successfully";?> error "; mail($to,$subject,$msg,$headers); echo "Message sent successfully"; ?> how to solve it?? Quote Link to comment Share on other sites More sharing options...
requinix Posted May 18, 2013 Share Posted May 18, 2013 You don't have PHP installed. The solution is to install PHP. Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 18, 2013 Author Share Posted May 18, 2013 the code is giving proper result on localhost..but i know to get mail i have to upload it on server ??? this problem is coming when i uploaded my script on hosting.... so how to install php there.. Quote Link to comment Share on other sites More sharing options...
requinix Posted May 18, 2013 Share Posted May 18, 2013 Are you sure your hosting supports PHP? Who do you have? Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 19, 2013 Author Share Posted May 19, 2013 It should be as my other php websites are running on it.... Its Hostmonster.com Quote Link to comment Share on other sites More sharing options...
requinix Posted May 19, 2013 Share Posted May 19, 2013 As long as PHP is installed, you're using the right file extension (typically .php, perhaps .php5), and you're using the long open tags (<?php) then the script should work. If it isn't working then probably one (or more) of those conditions aren't being met. Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 19, 2013 Author Share Posted May 19, 2013 so the code is correct........ may i try this code on another hosting?? Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 19, 2013 Share Posted May 19, 2013 so the code is correct........ may i try this code on another hosting?? No, it's not, The proper format should be From: user@domain.com will work// or quote a userNameFrom: "user" <user@domain.com> Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 19, 2013 Author Share Posted May 19, 2013 @jazzman1 sorry but not getting it.. can u give me the proper code.. using my example Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 19, 2013 Share Posted May 19, 2013 (edited) Take that and give us the result back if there is an error: <?php if (function_exists('mail')) { extract($_POST); $to = "sehgal_jas@yahoo.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers.= <<<EOD From: "$name" <$email> EOD; } else { echo 'mail() has been disabled'; exit; } // send message if (mail($to, $subject, $message, $headers)) { echo "mail send ... OK"; } else { echo "mail send ... ERROR!"; } Make sure that the "$subject" and the "$message" variables are defined! Edited May 19, 2013 by jazzman1 Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 19, 2013 Author Share Posted May 19, 2013 your code is giving syntax-error on line 15.. correct it so i can test it Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 19, 2013 Share Posted May 19, 2013 It's coming from the heredoc - EOD; Make sure that there is no an empty space before that one - EOD; (10 row) Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 19, 2013 Author Share Posted May 19, 2013 k.. syntax problem solved. i run the code... but a blank page is comings after processing... and no email in my mailbox Quote Link to comment Share on other sites More sharing options...
Solution jazzman1 Posted May 19, 2013 Solution Share Posted May 19, 2013 (edited) He-he, that's life php coding So, try that: <?php if (function_exists('mail')) { extract($_POST); $to = "sehgal_jas@yahoo.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers.= <<<EOD From: "$name" <$email> EOD; // send message if (mail($to, $subject, $message, $headers)) { echo "mail send ... OK"; } else { echo "mail send ... ERROR!"; } } else { echo 'mail() has been disabled'; exit; } Make sure all variables are defined in proper way. Edited May 19, 2013 by jazzman1 Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 19, 2013 Author Share Posted May 19, 2013 buddy same result again.. a blank page with no email in inbox Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 19, 2013 Author Share Posted May 19, 2013 (edited) and 1 more question about <<<EOD (heredoc) what exactly it do... i search the web , not get clear much,,,i think it is used to write multiple lines with single(') and double quotes(") ?? is it Edited May 19, 2013 by Jaswinder Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 19, 2013 Share Posted May 19, 2013 Blank page, no errors, no messages, no echoes ??? Put down error_reporting(-1) on the top of the file and come back again. Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 19, 2013 Author Share Posted May 19, 2013 still blank.. dont know whats happening?? shoul i try it on another hosting?? Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 19, 2013 Share Posted May 19, 2013 Just put down simple echo "Test page" and see if you get any result. Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 19, 2013 Author Share Posted May 19, 2013 its not showing that also... so i just changed the host.. its working great know and i got the email.. about <<<EOD (heredoc) what exactly it do... i search the web , not get clear much,,,i think it is used to write multiple lines with single(') and double quotes(") ?? is it and also about this line From: "$name" <$email> Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 19, 2013 Share Posted May 19, 2013 A here document is a special-purpose code block and allows me easily to quoting/escaping the strings effectively.About < (<) and > (>), there are html character entities, so to display for instance a less than sign we must write: < or <But...when you try to send emails you can use both of them, I think. For example:From: "$name" <$email> Quote Link to comment Share on other sites More sharing options...
Jaswinder Posted May 20, 2013 Author Share Posted May 20, 2013 thank you for such info and code..... can we use the same code when we have to send the mail to the sender ... Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 20, 2013 Share Posted May 20, 2013 can we use the same code when we have to send the mail to the sender ... No, especially if you're planning to send a mass of emails to our subscribers. You have to consider using some php mail library as swiftMailer or phpMailer 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.