We help IT Professionals succeed at work.

php.ini smtp problem

SteveMat11
SteveMat11 asked
on
I currently just installed PHP5 on IIS6 and having a problem with SMTP settings.  I edited my php.ini file in the PHP root dir.  I changed the SMTP server from localhost to the smtp server of my ISP.  I know that it doen't require auth and uses port 25.  After editing that, I restarted IIS.  After filling out the form on the webpage, i still receive the same 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

Apparently, it is still trying to use localhost as the mail server.  Can anyone tell me why???
Comment
Watch Question

Top Expert 2007

Commented:
> I edited my php.ini file in the PHP root dir.
This is not the php.ini IIS uses. Create an file with
<?php phpinfo();
Open that page via brwoser and check for:
Loaded Configuration File
Configuration File (php.ini) Path
and edit that file in that directory. Then restart IIS

Author

Commented:
It shows it in C:/windows, i went to that dir and do not see php.ini there.

Author

Commented:
line below that shows: Loaded Configuration File  (none)  
Top Expert 2007

Commented:
So copy your php.ini in from the php-root dir to c:\windows and restart IIS and try again.

Author

Commented:
Ok, that worked but now i get another error.  Code for the form is attached first, as well as the action page below it.  The error currently reads failed to send removal request.  Like I said, this code worked fine on an apache server.  Any ideas?  Thanks for your help
<html>
<head>
<title>Remove Me From A Class</title>
</head>
<body>
<form method="POST" action="remove_me.php">
<table border="0" cellspacing="5" cellpadding="5">
<tr>
<td>Name:</td><td><input type="text" name="name" size="25" /></td>
</tr>
<tr>
<td>Badge #:</td><td><input type="text" name="badge" size="25" maxlength="3" /></td>
</tr>
<tr>
<td>Class Name:</td><td><input type="text" name="className" size="25" /></td>
</tr>
<tr>
<td>Class Date:</td><td><input type="text" name="date" size="25" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Submit Request" />&nbsp;<input type="reset" name="reset" value="Reset" /></td>
</tr>
</table>
</form>
</body>
</html>
 
 
 
 
 
--------------
 
<?php
$name = $_POST["name"];
$badge = $_POST["badge"];
$className = $_POST["className"];
$date = $_POST["date"];
$to = "***MYEMAIL@MYEMAIL.COM***";
$subject = "Class Remove Request";
$message = "$name\n$badge\n$className\n$date";
 
if (empty($name) || empty($badge) || empty($className) || empty($date)) {
echo "Please Fill In All The Fields. <a href=\"removeme.php\">Back</a>";
}
else if (!empty($name) && !empty($badge) && !empty($className) && !empty($date)) {
 
	if (mail($to, $subject, $message)) {
	echo "Request Successfully Sent";
	}
	else {
	echo "Failed to send Removal Request";
	}
}
?>

Open in new window

Top Expert 2007

Commented:
Maybe your webserver is not allowd to deliver mails to that server. Ask the administrator of the mail-server to check the log or allow your webserver to deliver mails without authentication to that mailserver.

Author

Commented:
that is the address of our isp's mail server.  I am usually able to send mail through their server without a problem or authentication.  I require auth on my own server.  Any other ideas or address of a mail host that doesnt require auth?
Top Expert 2007
Commented:
Use a mailing class like http://phpmailer.sf.net or http://swiftmailer.sf.net which will produce better error messages if a mail could not get delivered.

Author

Commented:
I will change my php.ini file to include that smtp server.  Also, does the "from" email address in the line below that matter?

Author

Commented:
This actually worked.  I change the code around instead of using home made code.  

Explore More ContentExplore courses, solutions, and other research materials related to this topic.