Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed easyphp and I'm trying to send an email from my computer (server).

My PHP code:

$message = "Line 1\nLine 2\nLine 3";
$headers = "From:\r\n";
mail('', 'My Subject', $message, $headers);

Error message:

Warning: mail() [function.mail]: Failed to connect to mailserver at "" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\EasyPHP-\www\email.php on line 9

Now, do I need to install an email server? Is it mandatory?

Edit: I don't think that my ISP will allow me to send emails from their servers.

share|improve this question
up vote 2 down vote accepted

By default, PHP will try to send via a local SMTP server, which it's trying to do here.

What you'll need to do is edit your php.ini file, and find the SMTP option. Change it to read something like this:-

sendmail_from =

FAQ entry 55 on the EasyPHP FAQ tells you how to do this for EasyPHP.

share|improve this answer

Well you need to install an email server or configure it to use a readily existing one. From the easyPHP faq:

The "mail" function from PHP returns an error (0) ! You need to replace this line: SMTP="localhost" in your PHP conf file (php.ini) by SMTP="" where stands for the mail server of your ISP.

You will probably also find point number 6 here to be helpful.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.