Here is code for sending e-mail which I wrote down:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<title>Send Mail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<form action="Mail.php" method="post">
<table width="200" border="0">
    <td>To Whom  :</td>
    <td><input type="text" name="Target" size="50" value="Someone@somenet.com"></td>
    <td>Topic  :</td>
    <td><input type="text" name="Topic" size="50" value="Tryout"></td>
    <td>Message :</td>
    <td><textarea name="Message" cols="50" rows="10">Let's hope this message to be sent!</textarea></td>
    <td>How many  :</td>
    <td><input type="text" name="Num" size="10" value="1"></td>
    <td><input type="submit" name="Send" value="SEND IT!">    </td>
    <td><input type="reset"  name="Dont" value="Cancel"></td>
$Target =$_POST["Target"];
$Topic  =$_POST["Topic"];
$Num    =$_POST["Num"];
$Send   =$_POST["Send"];

for($i=1; $i<=$Num; $i++) { $Send=mail($Target, $Topic, $Message);
if ($Send) { echo "Your mail is sent."; } else { echo "Unexpected error!"; } }

And here is the given 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() in C:\Prog\Apache\Apache2\htdocs\EMail\Mail.php on line 40

What should I do? Please help me...

Edited by happygeek: fixed formatting

11 Years
Discussion Span
Last Post by AhmedHan

contact your webhost as it seems they have not properly set up the mail servers in the config files, or maybe you just weren't given permission


Sorry that I have forgot to write that my page is not on a web server. It is on my computer.
The PHP script is being run on "Apache 2.0 - PHP 5 - WinXP" platform.


So, how can I install a mail server to my computer. Isn't there a way for sending mail without setting the page onto an external (real) web server?


That is all OK.


For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time. If you use another mail program, such as qmail or postfix, be sure to use the appropriate sendmail wrappers that come with them. PHP will first look for sendmail in your PATH, and then in the following: /usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib. It's highly recommended to have sendmail available from your PATH. Also, the user that compiled PHP must have permission to access the sendmail binary.

what is this "SENDMAIL BINARY"?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.