I would like to send email through php code hosted locally.
<?php
$email = "myemail@local.com";
$titre = "My subject";
$message = "Text message !";
mail($email, $titre, $message);
?>
When I run this code, I get the following error :
Warning: mail() [<a href='function.mail'>function.mail</a>]: 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:\...
I went into the php.ini
file and it seems to be already well configured.
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
How can I fix this ?
Thank you
try this
You will need to install a local mailserver in order to do this. If you want to send it to external e-mail addresses, it might end up in unwanted e-mails or it may not arrive at all.
A good mailserver which I use (I use it on Linux, but it's also available for Windows) is Axigen: http://www.axigen.com/mail-server/download/
You might need some experience with mailservers to install it, but once it works, you can do anything you want with it.
I spent hours on this. I used to not get errors but mails were never sent. Finally I found a solution and I would like to share it.
It is configured to use
localhost:25
for the mail server.The error message says that it can't connect to
localhost:25
.Therefore you have two options: