By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Mail Function doesnot work

P: 8
Hi all, i want to send mail through php coding.but error displays. i am working in windows environment. please help..

PHP Coding:

<?php
$to = "anandh@yahoo.com";
$subject = "Example";
$txt = "Test a Mail Function!";
$headers = "From: karthick@rediffmail.com";
mail($to,$subject,$txt,$headers);
?>


Error 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:\Program Files\xampp\htdocs\textexample\mailfn.php on line 8

hoew to rectify this. please tell in detail...
Mar 2 '07 #1
Share this Question
Share on Google+
8 Replies


ak1dnar
Expert 100+
P: 1,584
There is No Problem in with the Coding.
Problem is with your php.ini file.

You have to set Your SMTP provider Address and PORT.
This File is Located at Windows folder.

Locate and uncomment SMTP settings with Your Values.

Expand|Select|Wrap|Line Numbers
  1. [mail function]
  2. ; For Win32 only.
  3. SMTP = your.ISP.com
  4. smtp_port = 25
  5.  
Mar 2 '07 #2

ronverdonk
Expert 2.5K+
P: 4,258
There is No Problem in with the Coding.
Problem is with your php.ini file.

You have to set Your SMTP provider Address and PORT.
This File is Located at Windows folder.

Locate and uncomment SMTP settings with Your Values.

Expand|Select|Wrap|Line Numbers
  1. [mail function]
  2. ; For Win32 only.
  3. SMTP = your.ISP.com
  4. smtp_port = 25
  5.  
and also: the initialization of 'sendmail_from'
Expand|Select|Wrap|Line Numbers
  1. ; For Win32 only.
  2. sendmail_from = yourname@yoursystem.com
Ronald :cool:
Mar 2 '07 #3

Atli
Expert 5K+
P: 5,058
and also: the initialization of 'sendmail_from'
Expand|Select|Wrap|Line Numbers
  1. ; For Win32 only.
  2. sendmail_from = yourname@yoursystem.com
Ronald :cool:
Adding a "From: me@mydomain.me" to the headers will also work.
Mar 2 '07 #4

ronverdonk
Expert 2.5K+
P: 4,258
Adding a "From: me@mydomain.me" to the headers will also work.
Sure does.

Ronald :cool:
Mar 2 '07 #5

100+
P: 127
sorry, i still cant solve the problem of my forget password, i have install and open the free smtp server, when i send the mail, it have a warning as below...
Warning: mail(): SMTP server response: 503 in C:\Apache2\Apache2\htdocs\forgotPassword.php on line 25
Error sending email
What should i do now??? thanks..
n i try to click on the start menu, run, den type 'telnet localhost 25'
it show me:
220 localhost
Mar 3 '07 #6

ak1dnar
Expert 100+
P: 1,584
Since you are accessing a remote SMTP server like smtp.gmail.com,
Your Server should connect to the Internet.Just Check it.Otherwise you can't send the mails from Local intranet to Internet.

Post your SMTP settings here.
Mar 4 '07 #7

100+
P: 127
Since you are accessing a remote SMTP server like smtp.gmail.com,
Your Server should connect to the Internet.Just Check it.Otherwise you can't send the mails from Local intranet to Internet.

Post your SMTP settings here.
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25


; For Win32 only.
sendmail_from = me@localhost.com
Emm.. wat should i do?? Thanks..
Mar 4 '07 #8

ak1dnar
Expert 100+
P: 1,584
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25


; For Win32 only.
sendmail_from = me@localhost.com
Emm.. wat should i do?? Thanks..
Dear Friend,
Have you configured this localhost as a SMTP server.I don't think so.
Try to find out real SMTP service provider.Normally for the SMTP facility you can use most of the email service providers.Because SMTP is Not like POP.
If you are running from a home-based server supply your ISP's mailserver as your SMTP host.


smtp.mail.yahoo.com
25
smtp.gmail.com
465 or 587

Some times You need the Authentication also.....
Mar 5 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.