473,769 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple mail problem

In my effort to learn PHP I'm playing with some simple email scripts. They
worked a few days ago but they stopped working. The only thing I've done to
this Windows 2000 PC in this time was a Windows Update which I do regularly.
The only part of this update that might be related was an IE 6 update.

So I uninstalled and reinstaled PHP 4.3.3. The mail server setting is correct
in the php.ini file. But email is still not being sent.

PHP seems to be working because I put an echo statement in the code that works.

Notice in the code below that if you don't put anything in the textboxes it's
supposed to give a friendly error message. It does not.

Can anyone give me tips on how to track down the source of why the mail send and
error messages don't work?

Thanks for your help.

The code follows:

<html>
<head>
<title>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

<?php function show_form($emai l="", $message="", $subject="") { ?>

<h2>Send Me an E-mail</h2>

<form action="mail.ph p" method="post">

Your E-mail address:<br>
<input type=text name=email size=30
value="<?php echo $email?>"><br>

The Subject:<br>
<input type=text name=subject size=30
value="<?php echo $subject?>"><br >

Your Message:<br>
<textarea rows=10 cols=50 name=message><? php echo $message?></textarea><br>

<input type=submit value="Send E-mail">
</form>

<?php }
if (!isset($email) or !isset($message )) {
show_form();
}
else {
if (empty($email) or empty($message) ) {
echo "<H1>There is a Problem:</H1>";
if (empty($email)) {
echo "I need your email address in order to write back.
Please fill it in below. Thank you.";
}
if (empty($message )) {
echo "You did not write anything. Please write something.
Thank You.";
}
show_form($emai l,$message,$sub ject);
}
else {
if (empty($subject )) {
$subject="your email";
}

$sent = mail( "nb@whatever.co m", $subject, $message, "From: $email" );

if ($sent) {
echo "<H1>Your Message Has Been Sent.</H1>";
echo "Thank you, <b>$email</b>. <p>I'll will read your email regarding
'
<b>$subject</b> and reply soon.";
}
else {
echo "<H1>There is a Problem:</H1>
<p>The server was unable to send your mail.";
}
}
}
?>

</body>
</html>
Jul 17 '05 #1
5 3107

Bruce W...1 <br***@noDirect Email.com> wrote in message
news:3F******** *******@noDirec tEmail.com...
In my effort to learn PHP I'm playing with some simple email scripts. They worked a few days ago but they stopped working. The only thing I've done to this Windows 2000 PC in this time was a Windows Update which I do regularly. The only part of this update that might be related was an IE 6 update.

So I uninstalled and reinstaled PHP 4.3.3. The mail server setting is correct in the php.ini file. But email is still not being sent.

PHP seems to be working because I put an echo statement in the code that works.
Notice in the code below that if you don't put anything in the textboxes it's supposed to give a friendly error message. It does not.

Can anyone give me tips on how to track down the source of why the mail send and error messages don't work?

Thanks for your help.

The code follows:

<html>
<head>
<title>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

<?php function show_form($emai l="", $message="", $subject="") { ?>

<h2>Send Me an E-mail</h2>

<form action="mail.ph p" method="post">

Your E-mail address:<br>
<input type=text name=email size=30
value="<?php echo $email?>"><br>

The Subject:<br>
<input type=text name=subject size=30
value="<?php echo $subject?>"><br >

Your Message:<br>
<textarea rows=10 cols=50 name=message><? php echo $message?></textarea><br>
<input type=submit value="Send E-mail">
</form>

<?php }
if (!isset($email) or !isset($message )) {
show_form();
}
else {
if (empty($email) or empty($message) ) {
echo "<H1>There is a Problem:</H1>";
if (empty($email)) {
echo "I need your email address in order to write back.
Please fill it in below. Thank you.";
}
if (empty($message )) {
echo "You did not write anything. Please write something.
Thank You.";
}
show_form($emai l,$message,$sub ject);
}
else {
if (empty($subject )) {
$subject="your email";
}

$sent = mail( "nb@whatever.co m", $subject, $message, "From: $email" );
if ($sent) {
echo "<H1>Your Message Has Been Sent.</H1>";
echo "Thank you, <b>$email</b>. <p>I'll will read your email regarding '
<b>$subject</b> and reply soon.";
}
else {
echo "<H1>There is a Problem:</H1>
<p>The server was unable to send your mail.";
}
}
}
?>

</body>
</html>

It looks like the dreaded register globals problem.

Try adding these four lines of code:

$vars = array_merge($HT TP_POST_VARS, $HTTP_GET_VARS) ;

$email = $vars['email'];
$message = $vars['message'];
$subject = $vars['subject'];


Jul 17 '05 #2
Jeff Darling wrote:


It looks like the dreaded register globals problem.

Try adding these four lines of code:

$vars = array_merge($HT TP_POST_VARS, $HTTP_GET_VARS) ;

$email = $vars['email'];
$message = $vars['message'];
$subject = $vars['subject'];

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

Not sure what you mean.

Well I stripped it down to bare bones and it successfully sent an email. See
code below. But I don't understand why the code in my original post doesn't
work. I have much to learn.

Code follows:

<html>
<head>
<title>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
Send mail
<?php
$to2 = "nb@whatever.co m";
$subject2 = "New whatever";
$body2 = "A new whatever was submitted";
$from2 = "From: au*********@wha tever.com";
mail($to2, $subject2, $body2, $from2);
?>
</body>
</html>
Jul 17 '05 #3
Jeff Darling wrote:

It looks like the dreaded register globals problem.

Try adding these four lines of code:

$vars = array_merge($HT TP_POST_VARS, $HTTP_GET_VARS) ;

$email = $vars['email'];
$message = $vars['message'];
$subject = $vars['subject'];


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

I think you're on to something. I set register_global s to On in php.ini and it
works properly. But I don't really understand this.
Jul 17 '05 #4

"Bruce W...1" <br***@noDirect Email.com> wrote in message
news:3F******** *******@noDirec tEmail.com...
In my effort to learn PHP I'm playing with some simple email scripts. They worked a few days ago but they stopped working. The only thing I've done to this Windows 2000 PC in this time was a Windows Update which I do regularly. The only part of this update that might be related was an IE 6 update.

So I uninstalled and reinstaled PHP 4.3.3. The mail server setting is correct in the php.ini file. But email is still not being sent.


One of the bugs reported for 4.3.3 is the mail() function not working.

I upgraded from 4.3.2 to 4.3.3, resulting in no more working mail()
function, I upgraded again to 4.3.4dev and mail() is now working again.

system: Windows XP pro running IIS5 and PHP CGI exe / Apache 2.47 and PHP
apache 2 module with the same php.ini for both.

Jul 17 '05 #5
Richard Hockey wrote:

One of the bugs reported for 4.3.3 is the mail() function not working.

I upgraded from 4.3.2 to 4.3.3, resulting in no more working mail()
function, I upgraded again to 4.3.4dev and mail() is now working again.

system: Windows XP pro running IIS5 and PHP CGI exe / Apache 2.47 and PHP
apache 2 module with the same php.ini for both.

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

Good to know. I'm running Windows 2000 and PHP build 4.3.3 with IIS. Mail()
does indeed work. The problem seems to be that I'm using a script meant for
register_global s to be On. It's Off in 4.3.3 and I'd just as soon leave it that
way.

PHP is not strong when it comes to tracing and error messages so I'm shooting in
the dark.

I rewrote it to avoid the register_global s problem, I think. See the code
below. And I put some echo messages in the code to find where the problem is
but they aren't working either. On the first postback it does nothing, it
doesn't hit any of my echo lines and it's driving me crazy without giving me any
error messages or anything. It's like it's not executing any code at all on
postback. It should do either the if or the else.

Code follows:

<html>
<head>
<title>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?php function show_form($emai l="", $message="", $subject="") { ?>

<h2>Send Me an E-mail</h2>

<form action="mail.ph p" method="post">

Your E-mail address:<br>
<input type=text name=email size=30 value="<?php echo $email ?>"><br>
The Subject:<br>
<input type=text name=subject size=30 value="<?php echo $subject ?>"><br>
Your Message:<br>
<textarea rows=10 cols=50 name=message><? php echo $message ?></textarea><br>
<input type=submit value="Send E-mail">
</form>

<?php }

if (!isset($_POST['email']) or !isset($_POST['message'])) {
//if (!isset($email) or !isset($message )) {
show_form();
echo "Showing form";
}
else {
echo "First else hit";

$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
$subject = $_REQUEST['subject'];

if (empty($email) or empty($message) ) {
echo "<H1>There is a Problem:</H1>";
if (empty($email)) {
echo "I need your email address in order to write back.";
}
if (empty($message )) {
echo "You did not write anything. Please write something.";
}
show_form($emai l,$message,$sub ject);
}
else {
echo "Second else hit";
if (empty($subject )) {
$subject="your email";
}

$sent = mail( "nb@whatever.co m", $subject, $message, "From: $email" );

if ($sent) {
echo "<H1>Your Message Has Been Sent.</H1>";
echo "Thank you, <b>$email</b>. <p>I'll will read your email regarding '
<b>$subject</b> and reply soon.";
}
else {
echo "<H1>There is a Problem:</H1>
<p>The server was unable to send your mail.";
}
}
}
?>

</body>
</html>
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3315
by: Alexander Ross | last post by:
I am trying to create a simple mail form (i.e. five fields, the users pushes send and using the mail function I get an email with their input values). The problem is that some people will be filling out the form in Hebrew. When someone fills out the form in Hebrew, I get an email with junk: סT.רT "ת.ת & "Tס~.רT" Tour dates: 22,5,02 to 22,6,03 א . ר.צTם ~T.o zע TTY .zT.-" '. עס.ק...
0
2214
by: Hal Vaughan | last post by:
I'm working with javax.mail.*. I have no problem with reading in messages. I'm not using multi-part messages or anything, I just use this setup: Session oSession = Session.getDefaultInstance(props, null); try { oStore = oSession.getStore("pop3"); oStore.connect(sInServer, sInName, sInPass); oFolder = oStore.getFolder("INBOX"); oFolder.open(Folder.READ_WRITE); oMessage = oFolder.getMessages();
6
7749
by: chuck amadi | last post by:
Hi , Im trying to parse a specific users mailbox (testwwws) and output the body of the messages to a file ,that file will then be loaded into a PostGresql DB at some point . I have read the email posts and been advised to use the email Module and mailbox Module. The blurb from a memeber of this list . Im not at work at the moment So I cant test this out , but if someone could take a look and check that im on the write track as this...
6
2240
by: Benny Alexander | last post by:
Hi, I am using a simple form 2 email program. I ama experienced programmer, But I feel very bad, as I am unable to fix this problem. All seems to be fine, But the mail is not reacing to my mail box. Here is the code! The form has just three values!
9
3282
by: savvy | last post by:
i'm trying to compile a simple console application for sending a mail, my main idea is to schedule it to a particular time for sending mails using the windows schedular task lateron. Therefore i need an exe file to make that work. I compiled my file Emailtest.cs using this command line csc /r:System.Web.dll Emailtest.cs and i got an .exe file but when clicking it or executing it i'm not receiving any mail. I dont know where the problem is...
5
1804
by: Logickle | last post by:
Hi, all. I'm working on an application which requires communicating session info between separate web apps running on the same web server. The out of process server method sounded ideal, and very simple to implement as far as I could tell. So I re-configured my apps' web.config and machine.config files from InProc to StateServer, and confirmed that's the mode used by both web apps. To keep it simple, I created two basic ASP.NET apps...
5
1172
by: Olivier/Noetika | last post by:
would like to send messages from my vb application with the user default mail software. That's to say preparing content, attachement and let user selecting the "to" option with it's own friends list. I had a close look to this community and web pages but I'm not really sure to find what I wanted I do not want to use outlook, as perhaps it's not the user mail software, I want to use default user software, not knowing it I do not want to use...
4
4261
by: Tony M | last post by:
VS 2005 - XP media - VB .net - winforms - .net 2.0 Just trying to send an email, here is the code and the error message that I get. I can't figure out how to fix it?
5
2306
by: simononestop | last post by:
Hi im totally new to perl this is my first go at using it (I normally use asp). I have set up a form with a cgi script from demon hosting. I have edited the script and the form works it sends me an email. however all the information is missing form the email I only get the first form text field?? #!/bin/perl # ------------------------------------------------------------
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.