Configuring PHP.ini file to use PHP mail Funtion on IIS 5.0 server
- From: caroline_harris@xxxxxxxxxxx
- Date: 2 Jul 2005 14:24:38 -0700
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.
.
- Follow-Ups:
- Prev by Date: Re: Frames
- Next by Date: Re: Frames
- Previous by thread: Frames
- Next by thread: Re: Configuring PHP.ini file to use PHP mail Funtion on IIS 5.0 server
- Index(es):
Relevant Pages
|
|