Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

My PHP code:

<?php
$message = "Line 1\nLine 2\nLine 3";
$headers = "From: sender@example.com\r\n";
mail('receiver@metu.edu', 'My Subject', $message, $headers);
?>

Error message:

Warning: mail() [function.mail]: Failed to connect to mailserver at "127.0.0.1" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\EasyPHP-5.3.3.1\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
add comment

2 Answers 2

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:-

SMTP = your.isp.mailserver.com
sendmail_from = sender@example.com

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

share|improve this answer
add comment

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="mail.isp.com" where mail.isp.com stands for the mail server of your ISP.

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

share|improve this answer
add comment

Your Answer

 
discard

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.