Jump to content

Failed to connect to mailserver at "localhost" port 25


Recommended Posts

Hi guys,

 

I have a form which is meant to post to my database as well send me an email.

 

It posts to the database very fine but it returns the following 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:\xampp\htdocs\site\reportingfaults.php on line 58

 

An not sure what to do, I am 2month new to PHP. I would appreciate your help in solving the problem.

 

Thanks.

 

Here is the code and form:

 

<?php 
// Parse the form data
if(isset($_POST['fault'])) {

    $fault = mysql_real_escape_string($_POST['fault']);

$sql = mysql_query("INSERT INTO csj_fault(fault, username, fault_date) 
        VALUES('$fault','$manager', now())") or die (mysql_error());

    //!!!!!!!!!!!!!!!!!!!!!!!!!    Email me    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    $to = "mailto:[email protected]";
$from = "$manager";
    $subject = "$manager reported a system fault";
    //Begin HTML Email Message
    $message = "$fault";

$headers  = "From: $from\r\n";
    $headers .= "Content-type: text\r\n";

    mail($to, $subject, $message, $headers);


   exit();

 header("location: index.php"); 
     exit();
}
?>

 

Form

                <form action="reportingfaults.php" method="post" enctype="multipart/form-data">
                 <table width="90%" border="0" cellspacing="0" cellpadding="6">
                      <tr>
                        <td align="right">Fault Description</td>
                        <td><label>
                      
                         <textarea name="fault" id="fault" cols="42" rows="5"></textarea>
                        </label></td>
                      </tr>
                      
                            <tr>
                        <td> </td>
                        <td><label>
                          <input type="submit" name="button" id="button" value="Send" />
                        </label></td>
                      </tr>
                      </table>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.