473,320 Members | 1,920 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,320 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 2264
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.