Mail() function is not going through

I got this warning after using the mail function. It seem not to be configure at the php.ini does anybody has any idea on how to fix it.

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:\wamp\www\step2.php on line 14

You need a mail server to be able to send mail. If you’re not going to run one on your own computer, then you need to put the details of the SMTP server you’ll use in your php.ini.

do you have any site where I can get SMTP server?

smtp.gmail.com (use authentication)
Use Authentication: Yes
Port for TLS/STARTTLS: 587
Port for SSL: 465

Copied from this link: http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

Are you on shared hosting, dedicated server or do you have a localhost server?

@PHPycho

It’s that a free gmail service?

Will have to get a gmail acouunt? I have one already.

will the configuration below go inside the php.ini?

smtp.gmail.com (use authentication)
Use Authentication: Yes
Port for TLS/STARTTLS: 587
Port for SSL: 465

php.ini

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
smtp.gmail.com (use authentication)
Use Authentication: Yes
Port for TLS/STARTTLS: 587
Port for SSL: 465

Something like that?

@Ruben K.

I have a local server and a hosted server.

I am getting the same error still, Can’t get to configure the DNS server in my localhost.

using this in the script to configure my php.ini


<?php //set SMTP in php.ini
ini_set("SMTP", "smtp.gmail.com");?>

The php.ini configuration is

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = mail.stores.com

but it is bringing a warning

Warning: mail() [function.mail]: Failed to connect to mailserver at “smtp.gmail.com” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in C:\wamp\www\step2.php on line 19

Can ask my host provider for the DNS server, or am I missing something else in the code?

I have used the toturial below and he talks about getting an DNS server, or ISP but I don’t know where to find those tools to make it work. I have asked my domain host server and they give me mail.domainname.com as the DNS server but that’s what I need for this purpose?