Configuring PHP.ini file to use PHP mail Funtion on IIS 5.0 server



Hello:

I am new to the PHP world. I would like to utilize the Mail function
within PHP, however, I cannot seem to get a simple mail form to work.
My configuration is listed below:

I have Installed:

1. PHP 5 - I have tested basic commands such as:

<?php

$cnt=0;
while($cnt <= 10)
{
$cnt++;
echo "Hello World<P>";
}
?>

and it is working fine.

2. Operating System - Windows 2K

3. Web Server - IIS 5.0

4. Built in Virtual SMTP Server


============

Goal:

To test web-based email applications locally on my system for
development purposes.

Problem:

I do not know if my mail configuration settings within my php.ini file
are correct. I currently have:

[mail function]
; For Win32 only.
SMTP = localhost ; for Win32 only
smtp_port = 25
sendmail_from= (my email address - it is hotmail account) ; for Win32
only

I also have no idea if I have properly configured IIS and the virtual
SMTP server correctly. I do not know what my server address would be. I
do not have a registered domain name, etc. Localhost is the only server
address I am familiar with when testing locally. In addition, it is
possible that sending emails to my hotmail account may be blocked. I do
not know where the basic application is failing, so it is difficult to
know where to begin.


This is the code that I am using for the form:

HTML Form:

!CODE BEGINS!


<h1> Email Form</h1>

<form method="post" action="cont.php">
Fields marked (*) must be filled in.
<p>
Your email address*
<br>
<input type="text" name="EmailFrom" size="60">
<p>
Your name
<br>
<input type="text" name="Name" size="60">
<p>
Subject
<br>
<input type="text" name="Subject" size="60">
<p>
Message*
<br>
<textarea name="Message" rows="15" cols="65"></textarea>
<p>
<input type="submit" name="submit" value="Submit">
</form>

!CODE ENDS!

>>>>>This is the PHP driving the form

!CODE BEGINS !

<?php

// get posted data into local variables
$EmailFrom = Trim($_POST[EmailFrom]);
$EmailTo = "John Doe <myemail@xxxxxxxxxxx>";
$Subject = Trim($_POST[Subject]);
$Name = Trim($_POST[Name]);
$Message = Trim($_POST[Message]);

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (Trim($Message)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=no.htm\">";
exit;}

// prepare email body text
// tells you that the mail is sent from this form
$Body .= "Message sent from email form:\n";
$Body .= "$Message";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: $Name <$EmailFrom>");

// redirect to success page
if ($success){print "<meta http-equiv=\"refresh\"
content=\"0;URL=yes.htm\">";}
else{print "<meta http-equiv=\"refresh\" content=\"0;URL=no.htm\">";}

// send copy of email to visitor
mail("$Name <$EmailFrom>", "John Doe has received your message
'$Subject'",
"You wrote: $Message", "From: John Doe <myemail@xxxxxxxxxxx>");
?>

!CODE ENDS!


So far the application routes me to the no.htm page. I would appreciate
any suggestions! Thanks.

.



Relevant Pages

  • Re: PHP Instalation problems. Browser doesnt know what to do
    ... This is loaded and run as a local server (for class ... PHP 5.2.0 from php-5.2.0-win32-installer.msi ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: PHP Instalation problems. Browser doesnt know what to do
    ... This is loaded and run as a local server (for class ... PHP 5.2.0 from php-5.2.0-win32-installer.msi ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • mysqli error?
    ... I'm just setting up my php enviroment and I typed in a simple script ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: php.ini settings not taking effect
    ... >don't have control over Apache's httpd.conf, as I'm running my php scripts on my ISP server. ... PHP configuration, at least for the Apache module version ... more settings here than you can with ini_set, ...
    (comp.lang.php)
  • RE: phpBB Worm
    ... the getpwent function is not supported on Windows. ... it probably depends on the web server ... I looked at the decoded Perl script, ... was invoked by PHP, which should have the Web server's permissions, ...
    (Bugtraq)