griffon Posted July 30, 2006 Share Posted July 30, 2006 Hi - I'm a newbie to PHP programing (about 3 days) so please forgive me if this is a really silly question.I want to write a php page to send reply e-mails to people contacting my website.I want to fully test any code on my local pc before uploading it to my website's server.So far I've succesfully downloaded, installed and configured PHP and Apache on my Windows xp machine.I've also written little test pages in php and they seem to work. So far so good.However, when I try to test a simple php page designed to simply send an email to myself it fails with the following error.[color=red]Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.myisp.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\Apache Group\Apache2\htdocs\PHP tests\send.php on line 3[/color][color=purple]*please note myisp and e-mails changed below[/color] From the error message, and reading around on the internet, it looks like the php can't get into my own ISP. I've tried modifying the php.ini file which initially looked like this:[mail function]; For Win32 only.SMTP = localhost ; for Win32 onlysmtp_port = 25sendmail_from= [email protected] ; for Win32 only to:[mail function]; For Win32 only.SMTP = smtp.myisp.com ; for Win32 onlysmtp_port = 25sendmail_from = [email protected] ; for Win32 onlyOK - I can't see how this can access my isp to send the e-mail because there appears to be no way to include my isp password. Just in case you ask - firewall configured to give apache access and, yes, apache was set to running.I'd be very grateful for any advice.Thanks:-) Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/ Share on other sites More sharing options...
unkownname Posted July 30, 2006 Share Posted July 30, 2006 username:[email protected] Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-65922 Share on other sites More sharing options...
griffon Posted July 30, 2006 Author Share Posted July 30, 2006 OK.Presumamby I insert this after the SMTP line below do I?[mail function]; For Win32 only.SMTP = smtp.myisp.com ; for Win32 onlysmtp_port = 25sendmail_from = [email protected] ; for Win32 onl Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-65934 Share on other sites More sharing options...
unkownname Posted July 30, 2006 Share Posted July 30, 2006 no stmp line is username:[email protected] just as you see it. Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-65938 Share on other sites More sharing options...
griffon Posted July 30, 2006 Author Share Posted July 30, 2006 Doesn't work I'm afraid. Same error. I believe the smtp I'm using is right. Could be the port number, I suppose. 25 seems right but how can I check what it wants I wonder? Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-65949 Share on other sites More sharing options...
unkownname Posted July 30, 2006 Share Posted July 30, 2006 hmm well theirs this php class on the net i forgot the name i think PHPSend look it up on google. Ill try looking for it sorry about that. Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-65954 Share on other sites More sharing options...
griffon Posted July 30, 2006 Author Share Posted July 30, 2006 thanks for helping. I have looked around the net and loads of people have had this or similar problems but no one seems to post the solution. Either they can't be bothered once they find it or they die solving it. LOL Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-65973 Share on other sites More sharing options...
wildteen88 Posted July 30, 2006 Share Posted July 30, 2006 mail doesnt support any authentication in order to login to sign in to an SMTP server to send an email, so doing username:[email protected] will not work or any other method. The SMTP address can only be smtp.hostname.com or IP based.In order for mail to work the SMTP server will need to be open to the public, as in no username/password set in order to send an email. Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-66049 Share on other sites More sharing options...
griffon Posted July 30, 2006 Author Share Posted July 30, 2006 OK. Thanks. That certainly seems to explain why this question often posed in help forums never seems to find an answer. There's some talk of people putting an e-mail server up on their PC to get around this problem. Which sounds a bit of a hassle. I guess I'll just have to upload the php to my web server and try it out there. Pity. I'd like to be able to test everything locally. Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-66091 Share on other sites More sharing options...
griffon Posted July 30, 2006 Author Share Posted July 30, 2006 [font=Verdana]"I guess I'll just have to upload the php to my web server and try it out there."[/font][color=red][/color]So, I did just that and my code works. Just like that! Thanks to all who had a go at helping me out. Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-66109 Share on other sites More sharing options...
tomfmason Posted July 30, 2006 Share Posted July 30, 2006 It sounds to me like you are using xampp or mecury mail if so try this$knownsender must me a vaild username on the server. Like [email protected][code=php:0]if ($ccaddress=="" || $ccaddress==" "){ $header="From: $knownsender"; }else{ $header .="From: $knownsender\r\n"; $header .=" Cc: $ccaddress";}// $header.="Bcc: $bcaddress";if (@mail($mailtos, $subject, $message, $header)) { echo "Your mail has been sent";}else{ echo "There was an error sending your Email";}[/code]I used to use xampp and it took for ever for me to get it right,not sure if this is correct but it works. Now for this to work You will need to change the php.ini back to the default. Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-66119 Share on other sites More sharing options...
griffon Posted August 2, 2006 Author Share Posted August 2, 2006 No. I'm with ntl actually. But thanks for your post. I think now I've had some success with uploading code onto my web site's server, I can test development code there rather than doing it on my local PC. I guess that's what most of you must do anyway. :) Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-67661 Share on other sites More sharing options...
wildteen88 Posted August 2, 2006 Share Posted August 2, 2006 griffon if you are with ntl, which I am you can use this in your php.ini:[code]SMTP = smtp.ntlworld.comsmtp_port = 25; For Win32 only.sendmail_from = [email protected][/code]In the php.ini, make sure you change [email protected] to your ntl email addy. And that you are using the computer connected to the ntl internet connection. Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-67745 Share on other sites More sharing options...
ronverdonk Posted August 2, 2006 Share Posted August 2, 2006 I have been testing my own email locally foir quite some time. Are you sure that the smtp.myip.com is a real SMTP server? You must use a real mail server and a real address.My normal email provider is planet.nl and their mailserver is mail.planet.nl, so I specified [b]SMTP = mail.planet.nl[/b]My sendmail_from is defined as [b]sendmail_from = [email protected][/b]Ronald ;D Quote Link to comment https://forums.phpfreaks.com/topic/16030-set-up-to-test-sending-emails-from-php-on-local-pc/#findComment-67753 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.