shihao Posted November 2, 2009 Share Posted November 2, 2009 Hi, guys, I try to send a email through php but unfortunately the mail unable to sent. Here is my code, any configuration that I need to change in order to send the email ? Anyone who know please help ? Thanks in advance. <?// send e-mail to ... $to="me@localhost"; // Your subject $subject="Test"; // From $header="from: your name <your email>"; // Your message $message="Hello \r\n"; $message.="This is test\r\n"; $message.="Test again "; // send email $sentmail = mail($to,$subject,$message,$header); // if your email succesfully sent if($sentmail){ echo "Email Has Been Sent ."; } else { echo "Cannot Send Email "; } ?> The error message "Cannot Send Email" shown Quote Link to comment Share on other sites More sharing options...
seanlim Posted November 2, 2009 Share Posted November 2, 2009 Turn on error reporting so that you know what exactly the error is. Check your php.ini, make sure that the proper SMTP server is selected. Quote Link to comment Share on other sites More sharing options...
phpretard Posted November 2, 2009 Share Posted November 2, 2009 It wont go if this is how you have it.. $header="from: your name <your email>"; change to $header="from: phpretard <email@youremail.com>"; Quote Link to comment Share on other sites More sharing options...
shihao Posted November 2, 2009 Author Share Posted November 2, 2009 Hi, seanlim, how to turn on the php error report, there is many php.ini file. I didn't use xampp, I had configure seperately. This is my php.ini, C:/php/php.ini , C:/program Files/apache group/apache2/php.ini C:/windows/system32/php.ini C:/Apache/htdocs/phpmyadmin/php.ini and which script that I shall change it? phpretard, I had change it to $header="from: phpretard <ngshihao@yahoo.com>"; it doesn't work either. Quote Link to comment Share on other sites More sharing options...
seanlim Posted November 2, 2009 Share Posted November 2, 2009 Use error_reporting(E_STRICT | E_ALL); ini_set('error_reporting', E_ALL); at the start of your script. Quote Link to comment Share on other sites More sharing options...
shihao Posted November 3, 2009 Author Share Posted November 3, 2009 Hi seanlim, The error message below shown: "Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()" Anyone who knows please help.. Thanks Quote Link to comment Share on other sites More sharing options...
shihao Posted November 3, 2009 Author Share Posted November 3, 2009 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:\Program Files\Apache Group\Apache2\htdocs\mail.php on line 19 sorry, ommit something.. Quote Link to comment Share on other sites More sharing options...
shihao Posted November 3, 2009 Author Share Posted November 3, 2009 I try localhost and leave it empty before, the error message still persists Quote Link to comment Share on other sites More sharing options...
seanlim Posted November 4, 2009 Share Posted November 4, 2009 If you don't have an SMTP server installed and running on your computer, you will have to change the settings in php.ini to point to an SMTP server that is running. Quote Link to comment Share on other sites More sharing options...
shihao Posted November 5, 2009 Author Share Posted November 5, 2009 Hi Seanlim, I am not good in this. :'( Can you be more specific? How I know whether my SMTP is installed and running? How I check what is the SMTP that running? Prompt reply is appreciated. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
scvinodkumar Posted November 5, 2009 Share Posted November 5, 2009 do u have hosting server, if yes then assign mail server details SMTP = mail.server.com smtp_port = port no ; For Win32 only. sendmail_from = email id without these you can't send mail from your local system. Quote Link to comment Share on other sites More sharing options...
shihao Posted November 5, 2009 Author Share Posted November 5, 2009 hi scvinodkumar, I just want to do at my own PC, localhost. Now my parameter is SMTP: localhost SMTP_port: 25 The error message that I get is: 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:\Program Files\Apache Group\Apache2\htdocs\mail.php on line 20 Quote Link to comment Share on other sites More sharing options...
seanlim Posted November 5, 2009 Share Posted November 5, 2009 You will need to install and run an SMTP server on your PC then. I have not attempted this before, but I believe it isn't hard. The alternative would be simply to use your ISP's SMTP server, which is what I do when I need to test out PHP mail functions on localhost. Quote Link to comment Share on other sites More sharing options...
shihao Posted November 9, 2009 Author Share Posted November 9, 2009 Hi everbody, Window XP SP3 don't have the IIS. I have install the Management and Monitoring tools. Seems that the problem still persists. Anyone has encounter this before? How to install the SMTP server?? Quote Link to comment Share on other sites More sharing options...
shihao Posted November 9, 2009 Author Share Posted November 9, 2009 New error message: Warning: mail() [function.mail]: SMTP server response: 550 bosauthsmtp02: Host 115.133.133.26: No unauthenticated relaying permitted in C:\Program Files\Apache Group\Apache2\htdocs\mail1.php on line 9 Quote Link to comment Share on other sites More sharing options...
chauffeur Posted November 9, 2009 Share Posted November 9, 2009 Go here http://www.phpfreaks.com/forums/index.php/topic,276125.0.html I put up a script that works. 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.