Help - Search - Members - Calendar
Full Version: email not sending
HTMLHelp Forums > Programming > Server-side Scripting
Hi, could I get some help understanding why an email isn't being sent out after the submit button is clicked?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

extract ($_POST);
<form action=" " method="post" name="test">  
Name: <input name="name " type="text" id="name " size="8" /><br />
email <input name="email" type="text" size="9" maxlength="30" /><br />
<input name="submit" type="submit" value="submit" />  
    $to = '';
    $Subject = "test message";
    $Msg = "is this working?";  
    mail($to, $Subject, $Msg, 'From' . $email);
echo " thank you for your order.  It is being processed.  Thank you for your business.";

Brian Chandler
What efforts have you made to debug the problem yourself?

For a start, although an *empty* action value is interpreted (more or less "officially") as meaning "submit to self", it's not clear if " " (a _space_) is always going to be interpreted as "empty". Personally I always write the URL of the page to be called, even if it's the same, since I like keeping things simple.

Secondly, the extract($_POST) (currently commented out) seems an Extremely Bad Idea. Where did you get it from? Do you understand what it does?

if you are asking if I just jump to this forum when it didn't work, no I didn't. This is my first time I have had to send an email after a form was submitted so I look in the two books I have which are PHP By Example and Head First PHP and followed their examples.
Darin McGrew
Mindapolis - To help you learn how to debug your program, we need to know what you've tried and where you're stuck. If you don't answer anyone's questions, then it's hard to figure out how to help you.

In addition to Brian's questions, what happens now when you call the form? What messages appear in the server logs?
Some of the articles listed here might be usefull to you:
I don't know what to say. I have followed the examples in those books and it still won't send an email.

The form displays fine and upon clicking submit it acts like it 's processing the form just fine. This might be a stupid question and I apologize if it is, but where are the server do I find the server logs?
Brian Chandler
Asking about how to find the server logs is emphatically not a stupid question. Please try to ask more questions like this!

The answer is a bit fuzzy: if you installed your own server, you should know, or read the server documentation for the default. If you use a hosting service, go to the support pages and look for "server logs". They should show you how to access them. But of course if you are using a hopeless "free" host, you may not get access or something else (but you will certainly be getting your money's worth.)

I don't think the server logs are the answer anyway. Just **DEBUG** the program. This means you print out messages to show yourself what is going on.

Is the mail() function being called? Before mail($x, $y, $z, $w), put


echo "<p>*** Calling mail(): <pre>

Do you understand what this code fragment is going to do? If you do, please say so. If you don't understand it at all, you are still trying to go too fast for yourself.

Look, if you try baking cakes, you can -- largely -- simply try recipes from random cookbooks. If one doesn't "work", just try another. But it is not feasible to write programs the same way.
Darin McGrew
where are the server do I find the server logs?
I'd start by looking in the directory /var/log but that's just a guess based on the systems I'm familiar with. Your system may put them somewhere else.
Brian Chandler
QUOTE(Frederiek @ Dec 22 2011, 01:19 AM) *

Some of the articles listed here might be usefull to you:

That has to be true, in some sense. Some of the articles might be useful. But how would the OP determine which was the one to read? Have you read some/any/all of them? If you recommend a particular article it would be useful, but a whole list of them?

I had a quick look at a couple "for beginners" type titles, and neither looked to me to be very good. They sort of assume you know what "debugging" means before you start...

I will answer your questions in a little bit but I just got off the phone with the hosting company and I'm very confused. First, they said about 10 emails would sent out yesterday which is about right because I tried to send test emails to myself but I never got them. Then they say the $to variable has to be the domain email, which doesn't make any sense to me. Say a customer orders something from your website, you would want to send them a receipt of what they paid for and in that case the $to variable would be $_POST['email'], right?
Darin McGrew
First, they said about 10 emails would sent out yesterday which is about right because I tried to send test emails to myself but I never got them.
Have you checked your spam folder?
Well, it will soon get full after the email addie has been posted here. Mindiapolis, I edited your fist post and changed the email address to a dummy one.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.