473,396 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Mail Function doesnot work

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
8 4286
ak1dnar
1,584 Expert 1GB
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
4,258 Expert 4TB
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
5,058 Expert 4TB
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
4,258 Expert 4TB
Adding a "From: me@mydomain.me" to the headers will also work.
Sure does.

Ronald :cool:
Mar 2 '07 #5
bb nicole
127 100+
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
1,584 Expert 1GB
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
bb nicole
127 100+
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
1,584 Expert 1GB
[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

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

Similar topics

3
by: GAT | last post by:
I have a e-mail function in serverside VB, how would i put html code in the body variable so when email is recieved it looks like html page in the body. right now it just shows up as text in the...
2
by: Venkat | last post by:
Hi, My HTML page doesnot work properly in Netscape 7.1. But works fine in Opera 7 and IE 6.0. I could not figure out the problem. If any one could/suggest it would be nice.. This piece of HTML...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
3
by: gugdias | last post by:
I'm coding a simple matrix class, which is resulting in the following error when compiling with g++ 3.4.2 (mingw-special): * declaration of `operator/' as non-function * expected `;' before '<'...
1
by: Atara | last post by:
In my WindowForms Application I have Control1 inside Control2 inside Control3 inside theMainForm. I have a scenario that Control1 should call/sendEvent to theMainForm. in response, theMainForm...
3
by: dave | last post by:
We have an application that works perfectly in-house (tested on 3 different servers). It uses Microsoft.Web.UI.WebControls.dll for menubars and toolbars. Problem Description: We uploaded...
1
by: jadeite100 | last post by:
Hi: I am using IE 6 SP2. My resize attribute does not work <body onresize="test1();">. When I resize my window, the resize event doesnot get call. I have a jsp page with an iFrame called...
3
by: Daniel Kraft | last post by:
Hi, I was curious whether or not to use the & operator when creating a function pointer. It seems, that both &func and plain func create a pointer of the appropriate function pointer type. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.