kee2ka4 Posted August 27, 2006 Share Posted August 27, 2006 Hi! I am using a mail() function in one of my php code. However I have getting the following error:Warning: mail() [function.mail]: 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:\wamp\www\Car_Project\Registration\Testingtutorial\register.php on line 121I am using Localhost, Could anyone please tell me what I have done wrong or what setting I am required to change...Thanks for any Help Regards,Keetan Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 27, 2006 Share Posted August 27, 2006 you need to set the mail in the php.ini Quote Link to comment Share on other sites More sharing options...
kee2ka4 Posted August 28, 2006 Author Share Posted August 28, 2006 Thanks for your reply, I have looked into the mail() function in php.ini and this is what there is:[mail function]; For Win32 only.SMTP = localhost; For Win32 only.;sendmail_from = me@example.com; For Unix only. You may supply arguments as well (default: "sendmail -t -i").;sendmail_path =; Force the addition of the specified parameters to be passed as extra parameters; to the sendmail binary. These parameters will always replace the value of; the 5th parameter to mail(), even in safe mode.;mail.force_extra_paramaters =Could you tell me what I need to change in that?Also I have found three files with php.ini extension these are php.ini-recommended (c:\wamp\php), php.ini (c:\wamp\apache2\bin), and php.ini-dist (c:\wamp\php) do I have to change the settings in all of them?Thanks for your Help...Regards,Kee2ka4 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 28, 2006 Share Posted August 28, 2006 You need to setup PHP to a an SMTP server. Youm might be able to use your ISPs maiul server if they have an smtp server, so thing like smtp.ispname.comThe defualt SMTP port is fine, as most SMTP servers run on port 25.NOTE: If your isp requires you to be logged into to send an email to the smtp server, you wont be able to use the mail function. As the mail function doesnt support any authentication protocols. Quote Link to comment Share on other sites More sharing options...
kee2ka4 Posted August 28, 2006 Author Share Posted August 28, 2006 Thanks for your reply. I just wanted to say that I am not using an ISP, I am using a localhost at the moment, and still the mail() is not working. Any suggestion? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 29, 2006 Share Posted August 29, 2006 Do you have an SMTP server installed locally? You need to install an SMTP server locally in order to send emails via localhost. Quote Link to comment Share on other sites More sharing options...
kee2ka4 Posted August 29, 2006 Author Share Posted August 29, 2006 Hi! Thanks for all the Responses! Could anyone point me to the Direction as to how to Install an SMTP server locally? I don't even know if I have an SMTP server. Sorry I am quite new to all this. ::)Btw my ISP is pipex and I am using my local host to view my php files and I am using Apache! I just want this mail() to work for me to proceed!Thanks.. Quote Link to comment Share on other sites More sharing options...
kee2ka4 Posted August 29, 2006 Author Share Posted August 29, 2006 I have changed the smtp from localhost to my isp smtp address, however I still get the same error message. The settings I am changed in php.ini is:[mail function]; For Win32 only.SMTP = smtp.dsl.pipex.comsmtp_port = 25After changing the smtp from localhost to smtp.dsl.pipex.com I still get the same error message. The error message I get is Warning: mail() [function.mail]: 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:\wamp\www\Car_Project\Registration\Testingtutorial\register.php on line 121I have gone through many tutorials and researched google pages but didn't get anywhere... Some say to install an smtp server, I even tried that and its just not workingCould anyone help me please? I really can't proceed without sorting this error out... Please give me some light to my problem...Regards,Kee2ka4.... Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 29, 2006 Share Posted August 29, 2006 It appears you havent restarted Apache. You need to restart Apache or what ever your server program is in order for the new php settings to come available. Quote Link to comment Share on other sites More sharing options...
kee2ka4 Posted August 29, 2006 Author Share Posted August 29, 2006 Hi! Thanks for your reply wildteen.... You were right I didn't restart my server but now the error message has changed... now it says the following...Warning: mail() [function.mail]: SMTP server response: 501 Bad address syntax in C:\wamp\www\Car_Project\Registration\Testingtutorial\register.php on line 121The mail() function code on line 121 is:[quote] mail($email_address, $subject, $message, "From: MyDomain Webmaster<me@example.com>\nX-Mailer: PHP/" . phpversion()); echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';[/quote]Any idea's what might be wrong? Cheeerss Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 29, 2006 Share Posted August 29, 2006 Looks like your $email_address variable is holding an invalid email address. Everythink else looks ok Quote Link to comment Share on other sites More sharing options...
kee2ka4 Posted August 29, 2006 Author Share Posted August 29, 2006 The $email_address seems to be fine cause it does successfully add the details to the database! The $email_address is the address that I enter in a form, its just a normal hotmail email account that I enter. I have even tried @yahoo.com @gmail.com and non of them work...?Any other cluess... if nothing works then I will have to upload it on a webhosting company, but i would really prefer to work on my localhost.... ::) Quote Link to comment Share on other sites More sharing options...
kee2ka4 Posted August 30, 2006 Author Share Posted August 30, 2006 Yes ;D! I have sorted out the Problem! It took me one whole day lololol ! What I did is I stopped using mail () function and instead replaced it with PHPMailer, this is a php class for sending out emails. Anyone that is having problems with mail(), go throught this tutorial, its is really helpfull...http://www.phpfreaks.com/tutorials/130/0.phpUnderstand the PHPMailer class and then apply it into your code! If you want your webform to send emails, and do many other things, use phpmailer, it will work perfectly. The only thing u need to change is the smtp address in the php.ini file. My ISP is pipex and therefore my SMTP = smtp.dsl.pipex.com. Thats it!Anyways.. I am off, thanks for all the help today!Regards, Kee2ka4 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.