0
votes

I would like to use the mail() function in local but I get this error :

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

Here is the concerned php.ini :

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.free.com
;http://php.net/smtp-port
smtp_port = 25

and sendmail_from = "my email adress"

Does someone know from where that could come from ?

Edit: Ok, I finally found out. the smtp was not smtp.free.com but smtp.free.fr.... Thanks for your help to each anyway.

2
Are you on a Windows machine, because that's the only place those particular php.ini settings apply. if you're on a unix-ish box, you'd need a local mail server/mta installed. - Marc B
And do you have a mailserver set up on your local machine? - andrewsi
@andrewsi He's trying to use smtp.free.com. - Brad
You are probably editing the wrong PHP.ini. Look out the output of phpinfo() and confirm that you are editing the PHP.ini currently in use. - Brad
@TanguyLemoine You should fix your question, indicating that your config is not taking effect. That's the real problem. - Brad

2 Answers

0
votes

Might want to use quotes around "smtp.free.com" since it's a string.

0
votes

I'm going to make the assumption that this is being run through a webserver (IIS or Apache I would presume - considering you're on Windows).

If this is the case, then your settings will generally only take effect after you have restarted the webserver.