By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,409 Members | 1,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,409 IT Pros & Developers. It's quick & easy.

What Else Do I Need?

P: n/a
I am just learning PHP. I just tried coding a php script which I saved
as

mail.php

----------------------------
<?
$name=$_POST['name'];
$email=$_POST['email'];
$comments=$_POST['comments'];
$to="pr******@upng.ac.pg";
$message="$name just filled in your comments form. They
said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Thanks for your comments.";
} else {
echo "There was a problem sending the mail. Please check that you
filled in the form correctly.";
}
?>
--------------------------------------------------
and a simple html file called

mailProcess.html
----------------------------------------------
<html>
<head>
<title></title>
</head>

<body>
<h2>Sending Mail using PHP scripting...</h2>
<form action="../mail.php" method="post">
Your Name: <input type="text" name="name"><br>
E-mail: <input type="text" name = "email"><br><br>
Comments<br>
<textarea name="comments"></textarea><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
----------------------------------------------------
which captured data from the user intended for
mail.php
script to process and eventually send an email message to the person
while at the same time display a Thankyou page.

The script is working fine but the question is how do I get the IF part
of the CONDITIONAL statement executed rather than the ELSE part.
Currently it is the ELSE part of the CONDITIONAL statement is being
executed despite me supplying valid email address.

What could be the problem? Should I have installed SEND::Mail or things
like that? I already have PHP 5 and Apache 2 installed on my PC which
runs Windows XP.

jofio

Jul 17 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
*** Jofio wrote/escribió (1 Jun 2005 00:24:04 -0700):
What could be the problem? Should I have installed SEND::Mail or things
like that? I already have PHP 5 and Apache 2 installed on my PC which
runs Windows XP.


Under Windows, you need to configure an external SMTP server that accepts
mail from you; check php.ini for the details. If your ISP's mail server
doesn't accept your mail, then you need to install a local one. Windows XP
Professional includes a mail server (check the "Add/Remove programs" icon).

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #2

P: n/a
..... Windows XP
Professional includes a mail server (check the "Add/Remove programs"
icon). .....
What could be the mail server's name ....I just checked and nothing
there listed appeared to be one.....
jofio

Jul 17 '05 #3

P: n/a
mail "Returns TRUE if the mail was successfully accepted for delivery,
FALSE otherwise".
it seems your mail is not accepted for delivery. this could be the
sendmail setting.

try to send some testmail first to yourself and turn on error reporting
to find out what actually happens.

2nd thing i noticed: you're using values from the $_POST array
unvalidated. that's ok for just trying on your pc, but should never be
done otherwise. best not to get used to it.

micha

Jul 17 '05 #4

P: n/a
*** Jofio wrote/escribió (1 Jun 2005 01:28:25 -0700):
.... Windows XP
Professional includes a mail server (check the "Add/Remove programs"
icon). .....

What could be the mail server's name ....I just checked and nothing
there listed appeared to be one.....


Translating from Spanish:

Add or remove Windows components->
Internet Information Server services (IIS)->
SMTP Service

Please note Home Edition does not include this program.
In any case, I'd first try your ISP's mail server. Just make sure you add a
valid "From" address. However, if your ISP requires SMTP authentication,
you cannot use mail(), you'd need an alternative.

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #5

P: n/a
Micha,

I figured out Ithat don't have a mail server on my PC (I am using my
PC as my development platform) which I have to refer to in the mail
section of the php.ini ...To be honest I have no experience whatsoever
in setting things in php.ini file. I might have to look around for
help.

jofio

Jul 17 '05 #6

P: n/a
Alvaro,

The Web server I am using is Apache 2 and PHP 5. I don't exactly know
if an email server that comes with IIS can be set up in the php.ini
file to work with Apache Web Server.

jofio

Jul 17 '05 #7

P: n/a
*** Jofio wrote/escribió (1 Jun 2005 03:13:54 -0700):
The Web server I am using is Apache 2 and PHP 5. I don't exactly know
if an email server that comes with IIS can be set up in the php.ini
file to work with Apache Web Server.


Mail server does not need to interact with Apache at all, it's PHP the one
who will deliver messages to mail server using port 25. PHP doesn't care
whether the mail server is local or remote.

In php.ini:

[mail function]
; For Win32 only.
SMTP = localhost

; For Win32 only.
sendmail_from = yo**@email.address
Have you actually tried using the same mail server you use to send your
regular mail?
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #8

P: n/a
Brother, you're correct in that I must try using the same mail server
that I use for regular mail. that will have to be the next thing I'll
try and do, but I'll have to gather the guts to ask our IT
director/administrator to tell me the path to the mail server (LOL).

However, all this time I was trying to get emails send off straight
from my PC to whoever. But the problem was my own stupidity in that
that I was all the time thinking that PHP doesn't need a mail server
for that purpose.

In the absence of a PC based mail server, I simply have no choice but
have to get in touch with the IT administrator and get mail server path
info.

Many thanks, brother

jofio

Jul 17 '05 #9

P: n/a
You do NOT need to set up a mail server on your computer, that's an
unnecessary complication. No ISP will refuse to send your outgoing mail!

Instead, you need to make sure that your mail headers are correctly formed
so that your ISP (or the recipient's) does not block your mail as SPAM. This
will occur if the "envelope from" address is different from the "from"
address. So you need two parameters that contain your from address in the
call to mail(), one plain address and one header. Check the PHP
documentation for details on how to set the mail headers.

ECRIA
http://www.ecria.com
Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.