473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

What Else Do I Need?

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
9 1874
*** 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
..... 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
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
*** 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
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
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
*** 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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: lkrubner | last post by:
I want to give users the power to edit files from an easy interface, so I create a form and a PHP script called "fileUpdate". It does a reasonable about of error checking and prints out some...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
8
by: werner | last post by:
Hi! I don't want to use eval() in order to parse a user-supplied formula. What alternatives do I have? PHP has no standard functionality for tokenizing or parsing expressions in this regard. ...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Languageâ€, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
53
by: jaso | last post by:
Can you give any comments on this code? I used one goto, is it bad? #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <assert.h> #define NOT_NULL 1
13
by: Protoman | last post by:
I'm getting an error: 10 C:\Dev-Cpp\Enigma.cpp no match for 'operator<' in 'i < (+cleartext)->std::basic_string<_CharT, _Traits, _Alloc>::end ()' Code: Enigma.hpp...
3
by: bb nicole | last post by:
I have did the company login and job post which means that company can post the job after they login in my webpage.. I had set company_ID(tablename:company) is foreign key of table job. But when i...
11
by: James R. Davis | last post by:
Yes, a newbie here. Though I am making progress, slowly, I am also getting more and more confused. With ASP, when I wanted to do something as trivial as updating a visitor counter, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.