abdulqadr Posted April 26, 2010 Share Posted April 26, 2010 Hello. I am a not PHP Genius, i tried to create a form to email script with php but got 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:\Inetpub\vhosts\mysite.com\httpdocs\feedback.php on line 27 Please assist me :'( ...below is the whole body of my script <? $ip = getenv("REMOTE_ADDR"); $message .= "Full Name : ".$_POST['name']."\r\n"; $message .= "Email : ".$_POST['email']."\r\n"; $message .= "Company : ".$_POST['company']."\r\n"; $message .= "Address : ".$_POST['address']."\r\n"; $message .= "Telephone : ".$_POST['phone']."\r\n"; $message .= "Comments : ".$_POST['details']."\r\n"; $message .= "-------------- ------------------------------\r\n"; $recipient = '[email protected]'; $subject = " Faboa Global Associates."; $headers = 'From: [email protected]' . "\r\n"; $headers .= $_POST['email']."\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $smtpinfo["host"] = "smtp.mysite.com"; $smtpinfo["port"] = "25"; $smtpinfo["auth"] = true; $smtpinfo["username"] = "info"; $smtpinfo["password"] = "faboademo"; if (mail($recipient,$subject,$message,$headers)) { header("Location: contact2.html"); } else { echo "ERROR! Please go back and try again."; } ?> Thank you already Link to comment https://forums.phpfreaks.com/topic/199765-warning-mail-functionmail-failed-to-connect-to-mailserver-at-localhost/ Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 Your script should be fine. The problem is that most local servers on your machine don't have an outgoing mail server installed (smtp). So you'll have to upload to a remote host who supports outgoing mail. Or installing a local smtp server like Mercury If you install XAMPP on your machine, it should come bundled with Mercury. Link to comment https://forums.phpfreaks.com/topic/199765-warning-mail-functionmail-failed-to-connect-to-mailserver-at-localhost/#findComment-1048497 Share on other sites More sharing options...
abdulqadr Posted April 26, 2010 Author Share Posted April 26, 2010 Oh! Okay thanks alot. I will get the mercury installed. and keep you posted. thanks for your response... Link to comment https://forums.phpfreaks.com/topic/199765-warning-mail-functionmail-failed-to-connect-to-mailserver-at-localhost/#findComment-1048520 Share on other sites More sharing options...
abdulqadr Posted April 26, 2010 Author Share Posted April 26, 2010 Hello. I have installed a local smtp server. Please how do i implement it into my script. Please Link to comment https://forums.phpfreaks.com/topic/199765-warning-mail-functionmail-failed-to-connect-to-mailserver-at-localhost/#findComment-1048558 Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 If you've got it installed and setup, if it running correctly on port 25. mail() should now work, since it will connect to the server automatically. Link to comment https://forums.phpfreaks.com/topic/199765-warning-mail-functionmail-failed-to-connect-to-mailserver-at-localhost/#findComment-1048562 Share on other sites More sharing options...
abdulqadr Posted April 26, 2010 Author Share Posted April 26, 2010 am sorry it is not working sir. Link to comment https://forums.phpfreaks.com/topic/199765-warning-mail-functionmail-failed-to-connect-to-mailserver-at-localhost/#findComment-1048578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.