email not sending |
email not sending |
Mindapolis |
Dec 20 2011, 09:58 PM
Post
#1
|
Member Group: Members Posts: 67 Joined: 2-April 11 Member No.: 14,256 |
Hi, could I get some help understanding why an email isn't being sent out after the submit button is clicked?
CODE <?php error_reporting(E_ALL); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php extract ($_POST); /*if(!isset($submit)) {*/ ?> <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" /> </form> <?php $to = 'nemo@example.com'; $Subject = "test message"; $Msg = "is this working?"; mail($to, $Subject, $Msg, 'From' . $email); /*} else { echo " thank you for your order. It is being processed. Thank you for your business."; }*/ ?> </body> </html> |
Brian Chandler |
Dec 21 2011, 02:43 AM
Post
#2
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
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? |
Mindapolis |
Dec 21 2011, 09:31 AM
Post
#3
|
Member Group: Members Posts: 67 Joined: 2-April 11 Member No.: 14,256 |
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 |
Dec 21 2011, 11:06 AM
Post
#4
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
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? |
Frederiek |
Dec 21 2011, 11:19 AM
Post
#5
|
Programming Fanatic Group: Members Posts: 5,146 Joined: 23-August 06 From: Europe Member No.: 9 |
Some of the articles listed here might be usefull to you: http://www.d.umn.edu/itss/training/online/.../php.html#debug
This post has been edited by Frederiek: Dec 21 2011, 11:19 AM |
Mindapolis |
Dec 21 2011, 11:25 AM
Post
#6
|
Member Group: Members Posts: 67 Joined: 2-April 11 Member No.: 14,256 |
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 |
Dec 21 2011, 12:13 PM
Post
#7
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
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 CODE echo "<p>*** Calling mail(): <pre> $x $y $z $w </pre>\n"; 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 |
Dec 21 2011, 12:13 PM
Post
#8
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
QUOTE 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 |
Dec 21 2011, 12:18 PM
Post
#9
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
Some of the articles listed here might be usefull to you: http://www.d.umn.edu/itss/training/online/.../php.html#debug 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... |
Mindapolis |
Dec 21 2011, 02:17 PM
Post
#10
|
Member Group: Members Posts: 67 Joined: 2-April 11 Member No.: 14,256 |
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 |
Dec 21 2011, 04:07 PM
Post
#11
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
QUOTE 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? |
pandy |
Dec 21 2011, 04:15 PM
Post
#12
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
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.
|
Lo-Fi Version | Time is now: 26th April 2024 - 04:02 AM |