Re: Configuring PHP.ini file to use PHP mail Funtion on IIS 5.0 server
- From: "steve" <a@xxxxx>
- Date: Tue, 5 Jul 2005 20:06:15 -0500
simple answer...open port 25 on your server, type in the rfc email commands
to send an email to a valid email account. note any errors that occur. see
if you receive said email.
if that works, then i'd say iis smtp is setup. if not...rtfm for iis smtp
configuration.
next, i would avoid using the mail function for iis like the plague! just
give your pick up directory writeable access to your IUSR_<computer name
here> account...and use php to write a valid email directly to file in that
directory. smtp will send it from there. you should know from sending an
email on port 25 (because you actually read the smtp rfc) what information
and format constitues a "valid" email. you could use the com function to
instanciate a cdonts object and send the email that way...but why!
it's a bitch to have a reasonably secure smtp server and still be able to
use the mail function successfully...hell, even if it's totally insecure
it's still a bitch.
and for GAWD'S SAKE, the FIRST thing you need to do is to NOT allow relaying
on your smtp server...don't be subject to spammer hijacking. you'll get your
server/ip blocked world-wide *and* your isp could drop you as a
customer...even if you are NOT the one originating the spam.
hth,
steve
<caroline_harris@xxxxxxxxxxx> wrote in message
news:1120339478.288114.218370@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| 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.
|
.
- References:
- Configuring PHP.ini file to use PHP mail Funtion on IIS 5.0 server
- From: caroline_harris
- Configuring PHP.ini file to use PHP mail Funtion on IIS 5.0 server
- Prev by Date: Re: PHP Script Sites
- Next by Date: arrays
- Previous by thread: Configuring PHP.ini file to use PHP mail Funtion on IIS 5.0 server
- Next by thread: sendemail protect email
- Index(es):
Relevant Pages
|
|