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 Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/ 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. Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-949291 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 protected]>"; Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-949303 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 <[email protected]>"; it doesn't work either. Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-949315 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. Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-949318 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 Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-949873 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.. Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-949886 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 Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-949971 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. Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-950930 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. Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-951547 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. Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-951557 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 Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-951654 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. Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-951662 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?? Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-954033 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 Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-954075 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. Link to comment https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/#findComment-954099 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.