473,471 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Failed to connect to mailserver error in mail() function

Dipen Mehta
16 New Member
i try to change following code into the php.ini file
SMTP = smpt.gmail.com
smtp_port = 465


sendmail_from = mddipen@gmail.com

when i try to use mail function that time it will give me the following error so give me the proper configuration line to send mail in gmail account.

i am currently use iis for run php program.
Following is my code of email.php file:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(mail('mddipen@gmail.com','test subject','test message'))
  3.     echo('ok');
  4. else
  5.       echo('not ok');
  6. ?>

Following is my error message:
Warning: mail() [function.mail]: Failed to connect to mailserver at "smpt.gmail.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in E:\revant\New Folder\email.php on line 3
not ok
Attached Files
File Type: txt email.txt (141 Bytes, 403 views)
Jun 18 '11 #1
4 3610
Markus
6,050 Recognized Expert Expert
PHP's native mail is only a very basic interface. Instead, take a look at SwiftMailer.
Jun 18 '11 #2
Dipen Mehta
16 New Member
thank you,
But i still not send the mail.can you give me code for sending mail(edit my above code)? please send all library files related that code because in swiftmailer library files are missing.
Jun 18 '11 #3
Niheel
2,460 Recognized Expert Moderator Top Contributor
The error you are getting is more likely because in your mail server is set as smpt.gmail.com instead of smtp.gmail.com.

That could be your problem. Your mail function code looks right the server. So check your php.ini again or where ever you set your mail server settings.
Jun 18 '11 #4
Markus
6,050 Recognized Expert Expert
I wont write the code for you, no. The link I provided previously shows how to send mail via GMail. PHP's mail facilities aren't able to do this without other libraries because GMail requires TLS and other configurations.
Jun 18 '11 #5

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

Similar topics

3
by: vishal | last post by:
i am getting following error. Warning: mail() : Failed to connect to mailserver at "smtp.gmail.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in...
0
by: chris.huh | last post by:
I have setup Apache and PHP on my local machine as a testing server. So to test the mail() function i have set the SMTP_host thing in php.ini to what i think is the hotmail SMTP server. Whenever...
13
Nert
by: Nert | last post by:
hello every one, i need help.. how can i use the mail() funtion in php? when ever i execute the mail function i continuesly receive this error message: what do i need to do in order for me...
1
by: anandaraman | last post by:
Hi all. i need help from u. i use the mail function, but error displays. how to rectify. please help the coding is <?php $to = "somebody@example.com"; $subject = "My subject"; $txt = "Hello...
8
by: anandaraman | last post by:
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 =...
4
by: sravani1 | last post by:
Hi, I run the following code error will occure. Plz tell that what mistake i have done <?php // multiple recipients $to = 'sravani_409@yahoo.com' . ', '; // note the comma $to .=...
3
by: matiruv | last post by:
Warning: mail() : Failed to connect to mailserver at "192.168.0.254" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\selection\Untitled-6.php on line 16...
4
borisding
by: borisding | last post by:
Hi there, Well, I really need help from someone here, and hope that someone will answer my question and solve my problem. I know it's very common question and being asked by many developers: ...
14
by: Warren Tang | last post by:
Hi I am using the mail function to send a mail like this: $b = mail("my_real_email_address@gmail.com", "Hello from PHP", "Hi, finally sent an email successfully"); But it failed. Could you...
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.