kamal213 Posted June 28, 2011 Share Posted June 28, 2011 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:kamal.musah@yahoo.com"; $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> Quote Link to comment https://forums.phpfreaks.com/topic/240598-failed-to-connect-to-mailserver-at-localhost-port-25/ Share on other sites More sharing options...
trq Posted June 28, 2011 Share Posted June 28, 2011 Besides the fact that you have some weird 'mailto:' string pre-pended to your address, do you actually have a mail server installed, configured and running? Quote Link to comment https://forums.phpfreaks.com/topic/240598-failed-to-connect-to-mailserver-at-localhost-port-25/#findComment-1235814 Share on other sites More sharing options...
kamal213 Posted June 28, 2011 Author Share Posted June 28, 2011 I dnt kno coz am dump. I just installed xammp server which automatically installed everything else for me so I wouldn't know..Is there a way I can check? Quote Link to comment https://forums.phpfreaks.com/topic/240598-failed-to-connect-to-mailserver-at-localhost-port-25/#findComment-1235817 Share on other sites More sharing options...
kamal213 Posted June 28, 2011 Author Share Posted June 28, 2011 Also thorpe, I just google 'send email from comment box' and so people using 'mailto:' so I just added that without actually know what it meant hoping it would work Quote Link to comment https://forums.phpfreaks.com/topic/240598-failed-to-connect-to-mailserver-at-localhost-port-25/#findComment-1235818 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.