sln7 Posted April 3, 2007 Share Posted April 3, 2007 Hi folks, This might be the easiest question you've ever answered.. I would like to know how the mail() function works, as when I run the following script I am getting an error: <?php ini_set('SMTP', 'localhost'); ini_set('smtp_port', '25'); $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if (mail($to, $subject, $message, $headers)) { echo "success"; } else { echo "failed"; } ?> The error that I am getting is: [Tue Apr 03 00:12:26 2007] [error] [client 127.0.0.1] PHP Warning: mail() [<a href='function.mail'>function.mail</a>]: 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:\\Work\\Mysite\\mailAction.php on line 11 so basially i would like to know how i can send an email using my localhost.. PLEASE HELP Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/ Share on other sites More sharing options...
kenrbnsn Posted April 3, 2007 Share Posted April 3, 2007 Do you have a mailserver running on your localhost listening on port 25? Ken Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/#findComment-220321 Share on other sites More sharing options...
mmarif4u Posted April 3, 2007 Share Posted April 3, 2007 If yes ur mailserver is ok then also trythis: ini_set(SMTP,"mail.ebscon.com"); ini_set(smtp_port,25); Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/#findComment-220322 Share on other sites More sharing options...
sln7 Posted April 3, 2007 Author Share Posted April 3, 2007 Hi, I don't have a mail server running on my localhost. If I can download and configure a simple mail server, could you PLEASE offer any suggestions? Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/#findComment-220818 Share on other sites More sharing options...
per1os Posted April 3, 2007 Share Posted April 3, 2007 you also have to make sure that your ISP does not block PORT 25 before venturing into setting a webserver. Most hosts block that port due to spammers. Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/#findComment-220822 Share on other sites More sharing options...
trq Posted April 3, 2007 Share Posted April 3, 2007 If I can download and configure a simple mail server, could you PLEASE offer any suggestions? You really do not want to go there unless you know what your doing. Most isps will provide you with a server you can use. Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/#findComment-220830 Share on other sites More sharing options...
sln7 Posted April 4, 2007 Author Share Posted April 4, 2007 Thanks for the information. I was given smtphm.sympatico.ca as my smtp server by my isp. So i tried setting my smtp to that (SMTP = smtphm.sympatico.ca in PHP.ini), and ran my code again.. but no luck.. Is there anything else that I need to configure? Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/#findComment-220844 Share on other sites More sharing options...
trq Posted April 4, 2007 Share Posted April 4, 2007 You will want to set the sendmail_from attribute in your ini file to a valid (your) email address. Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/#findComment-220851 Share on other sites More sharing options...
sln7 Posted April 4, 2007 Author Share Posted April 4, 2007 Hi Thorpe, Thank you for your help so far. Now I am getting this error message: "SMTP server response: 530 5.7.0 Must issue a STARTTLS command first". Any help would be appreciated! Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/#findComment-220869 Share on other sites More sharing options...
sln7 Posted April 4, 2007 Author Share Posted April 4, 2007 I think I know how to solve this now..It needs authentication. If I configure my mailer through control panel, it should hopefully fix it..If I am wrong, correct me please.. Thanks for all your help. Quote Link to comment https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/#findComment-220874 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.