I have checked and double checked my settings and everything here, and scoured forums for HOURS. I have posted here before. Then I Googled for MORE HOURS. I cannot for the life of me find out what is wrong.
I would really appreciate some help. 🙂
Web Server: Win2000 IIS 5
Mail Server: UNIX (Postfix)
Problem: trying to send a form via the mail() function. I get the following error message:
Warning: mail() [function.mail]: Failed to connect to mailserver at "mail.server.name" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in f:\Inetpub\wwwroot\forms\submittest.php on line 46
My PHP code is:
<?
ini_set("SMTP","addr.umd.edu"); //changes default setting in php.ini
ini_set("sendmail_from","addr@addr.umd.edu");
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$deptroom=$_POST['Dept_RM'];
$completedate=$_POST['completedate'];
# $submitdate=$_POST['submitdate'];
$publications=$_POST['publications'];
# $publication_other=$_POST['publication_other'];
$title=$_POST['title'];
$papersize=$_POST['papersize'];
$total_pages=$_POST['total_pages'];
$num_copies=$_POST['num_copies'];
# $color=$_POST['color'];
# $bright=$_POST['bright'];
# $handout=$_POST['handout'];
# $miscellaneous=$_POST['miscellaneous'];
$cutting=$_POST['cutting'];
$folding=$_POST['folding'];
$copywork_other=$_POST['copywork_other'];
# $distribution=$_POST['distribution'];
$distribution=$_POST['distribution_other'];
# $website=$_POST['website'];
$website_other=$_POST['website_other'];
$other_instr=$_POST['other_instr'];
$to="addr@addr.umd.edu";
$headers="From: [email]addr@addr.umd.edu[/email]\r\n";
$headers.="MIME-Version: 1.0\r\n";
$headers.="Content-type: text/html\r\n";
$headers.="charset=iso-8859-1\r\n";
$message="$name has just submitted a Marketing Request. They said:\r\n$other_instr\r\n\r\nTheir e-mail address was: $email .\r\n";
echo "<html><head><title>Form Submission</title>\r\n\r\n";
echo "<style type=\"text/css\"><!--\r\n";
echo "body {margin-left:12.5%; margin-right:12.5%}\r\n";
echo "--></style></head><body>\r\n\r\n\r\n";
if (mail($to,"Request",$message,$headers))
{
echo "<h1>Form Submitted.</h1>\r\n\r\n";
echo "<p>\r\nThanks for your comments.</p>\r\n\r\n";
echo "<p style=\"font-weight:bold\">\nThe following info was submitted:</p>\r\n\r\n";
echo "<p style=\"color:navy; background:#eee; padding:1em; font:normal normal normal small/1.5 Georgia,serif\">\r\n";
echo "$name <br />\r\n";
echo "$email <br />\r\n";
echo "blah blah blah</p>";
} else {
echo "<h1 style=\"color:red\">Error.</h1>\n\n";
echo "\r\n<p>\r\nThere was a problem sending the mail. Please check that you filled in the form correctly.</p>";
}
echo "\r\n\r\n\r\n</body></html>";
?>
Yes, the mail server name is correct.
Yes, the SMTP port is 25.
Yes, I am going crazy here!