Jump to content

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost"


abdulqadr

Recommended Posts

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 ;)

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.

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.