eldan88 Posted July 12, 2013 Share Posted July 12, 2013 Hey, I am learning on how to use the mail function in PHP and have wrote one in PHP. Every time I try to execute it, I get an the message that says error. I have scanned through my code and everything seems to correct. Do you guys have any suggestions? Thanks <?php $to = "[email protected]"; $subject = "Mail Test at ".strftime("%T", time()); $message = "This is a test."; // Optional: Wrap lines for old email programs // wrap at 70/72/75/78 $message = wordwrap($message,70); $from = "[email protected]"; $headers = "From: {$from}"; $result = mail($to, $subject, $message, $headers); echo $result ? 'Sent' : 'Error'; // I get an "Error" every time I run this page ?> Quote Link to comment https://forums.phpfreaks.com/topic/280089-need-help-using-the-mail-function/ Share on other sites More sharing options...
doddsey_65 Posted July 12, 2013 Share Posted July 12, 2013 Are you running this script locally? If so, do you have a mail server setup so that the mail is actually sent? Also you could add this to the top to get descriptive errors: ini_set('display_errors','on'); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/280089-need-help-using-the-mail-function/#findComment-1440414 Share on other sites More sharing options...
eldan88 Posted July 16, 2013 Author Share Posted July 16, 2013 Are you running this script locally? If so, do you have a mail server setup so that the mail is actually sent? Also you could add this to the top to get descriptive errors: ini_set('display_errors','on'); error_reporting(E_ALL); Are you running this script locally? If so, do you have a mail server setup so that the mail is actually sent? Also you could add this to the top to get descriptive errors: ini_set('display_errors','on'); error_reporting(E_ALL); Hey, I am using a mac, and figured that I have a send mail application installed as a mail server. I am trying to send this locally. Will it work if I install PHP mailer?? Sorry I am really new to this! Quote Link to comment https://forums.phpfreaks.com/topic/280089-need-help-using-the-mail-function/#findComment-1440856 Share on other sites More sharing options...
eldan88 Posted July 16, 2013 Author Share Posted July 16, 2013 By the way, I tested it out on my remote server and it worked well. Quote Link to comment https://forums.phpfreaks.com/topic/280089-need-help-using-the-mail-function/#findComment-1440857 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.