473,425 Members | 1,899 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,425 software developers and data experts.

mail() fails to connect to SMTP server

28
Hai Friends..

I am using the simple form of mail() function. I am giving the code down.I am writing code for mail sending function in a feedback form. The mails are always sent to the variable $this->to_mail in the code and the visitors are putting their mail id in $this->from_mail in code.

Expand|Select|Wrap|Line Numbers
  1.                 if(isset($_POST['sub']))
  2.         {
  3.             echo "The Post is not empty";
  4.             $this->from_mail = $_POST['frm_mail_id'];// 
  5.             $this->mail_header = "From: $this->from_mail";
  6.             echo "The Header is : ".$this->mail_header;
  7.             echo "The Sender's Mail Id is : ".$this->from_mail;
  8.             $this->to_mail = "syammohan_ch@yahoo.com";
  9.             $this->subject = $_POST['subject'];
  10.             echo "The Subject is : ".$this->subject;
  11.             $this->message = $_POST['message'];
  12.             echo "The Message is : ".$this->message;
  13.              mail($this->to_mail,$this->subject,$this->message,$this->mail_header);

but i am getting the error saying that

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()

my php.ini settings are
Expand|Select|Wrap|Line Numbers
  1. [mail function]
  2. ; For Win32 only.
  3. SMTP = localhost
  4. smtp_port = 25
  5.  
  6. ; For Win32 only.
  7. sendmail_from = me@example.com
  8.  
  9.  
  10.  
  11. thanks in advance..
  12.             //$this->doMail();
  13.  
  14.         }
[Please use CODE tags when posting source code. Thanks! --pbmods]
Jun 29 '07 #1
5 2266
ronnil
134 Expert 100+
you need to configure php to a proper SMTP server. By default the server is set to localhost.

Go into your e-mail program, and find out what SMTP server you send your regular e-mails through, then insert this information in php.ini.

You can ofcourse also setup an SMTP server on your localhost for testing needs. I'm afraid I don't have any links to one atm.
Jun 29 '07 #2
syam
28
Please tell me how do i find out my smtp server name
Jun 29 '07 #3
ronnil
134 Expert 100+
It depends on which e-mail program you use. But basically you can see it under account settings.
Jun 29 '07 #4
kovik
1,044 Expert 1GB
You may want to try Swiftmailer. Very easy and has docs on SMTP connection.
Jun 29 '07 #5
pbmods
5,821 Expert 4TB
Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as 'please help' actually get FEWER responses?).
Jun 29 '07 #6

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

Similar topics

3
by: Shannon Clyde | last post by:
SMTP + relay + auth in an IPSEC tunnel to connect to our primary SMTP mail server (GroupWise) from the Web server looks like it would work fine, but is it the best way? I am aware of CDOSYS and...
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 -------------------------------------------------------------------------------- ...
5
by: ElanKathir | last post by:
Hi ! I wrote one code for Send the E-mail, But that code have some problem , So please help me Here i paste my code and Error: Error: Server Error in '/Elan_Sample' Application. ...
5
by: Charlie | last post by:
Hi: I'm working on an e-commerce site. Using the SMTP class, my site sends out confirmation messages. It works most of the time, but sometimes raises an error. I need a way of making sure it...
9
by: B-Dog | last post by:
I've built a small app that sends mail through our ISP's SMTP server but when I try to send through my local exchange server I get CDO error. Does webmail use SMTP or does it strictly rely on...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
0
by: Neo Geshel | last post by:
I am experiencing an inconsistency with System.Net.Mail. I have a web form on a site. The form gets filled, and one copy gets sent to the recipient (info@domain.com). This works just fine. ...
2
by: softbreeze | last post by:
Operating systems: Windows 2003 Enterprise ASP.Net 2.0, IIS 6.0, *** SMTP is not installed *** I have a corporate network that has an SMTP server (10.254.3.30) on it. I have a subnet (10.5.42.0)...
5
by: sui | last post by:
this is my code import sys, os, glob, datetime, time import smtplib ## Parameters for SMTP session port=587 SMTPserver= 'smtp.gmail.com' SMTPuser= '...@gmail.com' pw= 'fill in here'...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.