m0nk Posted May 29, 2009 Share Posted May 29, 2009 Hello everyone, First off I'd like to let you know that I am new to PHP and am just learning the basics at this point. what I've created is a simple php file that is supposed to send data from a web form and e-mail it to me, but unfortunately it's not sending me the e-mail with the data. When this happened I found a tutorial and entered the php text line by line with the guy in the tutorial but when i ran it, I still had the same issue of it not sending me an e-mail. I'll post my code below, but does anyone know why it might not be sending me the e-mail? In his tutorial it seemed to work perfectly but mine doesn't . If anyone is curious what tutorial I found it was at from tutvid. I've also tried sending it to three different e-mail addresses including yahoo, gmail, and my work e-mail so I know my syntax where I put in my e-mail was correct. Also, my webhost DOES support php so I don't think that's the issue either....and I have checked and double checked the names of my variables and they match the variables on my web form perfectly.... Any help would be GREATLY appreciated. Here is the code... <?php /* Subject and Email Variablees */ $emailSubject = 'Crazy PHP Scripting!'; $webMaster = 'your@email.com'; /*edited out for the forum post*/ /* Gathering Data Variables */ $emailField = $_POST['email']; $nameField = $_POST['name']; $phoneField = $_POST['phone']; $budgetField = $_POST['budget']; $travelersField = $_POST['travelers']; $commentsField = $_POST['comments']; $newsletterField = $_POST['newsletter']; $body = <<<EOD <br><hr><br> Email: $emailField <br> Name: $nameField <br> Phone Number: $phoneField <br> Budget: $budgetField <br> Number of Travelers: $travelersField <br> Comments: $commentsField <br> Newsletter: $newsletterField <br> EOD; $headers = "From: $emailField\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <title>JakesWorks - travel made easy-Homepage</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } --> </style> </head> <div> <div align="left">Thank you for your interest! Your email will be answered very soon!</div> </div> </body> </html> EOD; echo "$theResults"; ?> Quote Link to comment Share on other sites More sharing options...
fullyscintilla Posted May 29, 2009 Share Posted May 29, 2009 can u put your code in tags please are you recieving the emails at your other emails? if you are then the problem is with your other email address. Maybe your email host is flaggin the emails as spam or infected. I've seen some do this before, they like to flag them if they are really small sizes. Don't know why Quote Link to comment Share on other sites More sharing options...
m0nk Posted May 29, 2009 Author Share Posted May 29, 2009 Sure! I just registered today so I didn't know to do that...as soon as i figure it out I will for sure. Actually I'm not getting e-mails at any of the e-mail addresses that I specify, so I'm not sure what the issue is, especially since the code on the tutorial that the guy used worked fine and it's identical to mine. One thing that I noticed on one line is $success = mail() that goes directly into the mail() function. From previous programming experience I don't see anything calling the $success variable to initiate the function mail(), so when I troubleshooted it and I deleted the $success variable to just have the php program run mail(), it still didn't send the e-mail ??? Man I'm completely stumped.... Quote Link to comment Share on other sites More sharing options...
fullyscintilla Posted May 29, 2009 Share Posted May 29, 2009 are you throwing up ne errors?? Do you have error reporting on? can you also post the code that sends the mail. Quote Link to comment Share on other sites More sharing options...
m0nk Posted May 29, 2009 Author Share Posted May 29, 2009 That I don't know...I did it in Dreamweaver and I'm not getting any errors when I save it...should I be putting it into a different program? Quote Link to comment Share on other sites More sharing options...
fullyscintilla Posted May 29, 2009 Share Posted May 29, 2009 omg shut off dreamweaver and uninstall it .. then open up the php file in a text editor or notepad. you'll see the errors when you run the file through your browser.. Quote Link to comment Share on other sites More sharing options...
m0nk Posted May 29, 2009 Author Share Posted May 29, 2009 wouldn't it be easier just to put it in another program to debug it..? I mean I need dreamweaver to develop my web pages..... Quote Link to comment Share on other sites More sharing options...
m0nk Posted May 29, 2009 Author Share Posted May 29, 2009 I guess what I'm trying to ask is if there is something blatantly wrong with my code, or if in theory, after reviewing it, it should work? And if so if you have any suggestions as to what might be the issue with it not sending me e-mails... Quote Link to comment Share on other sites More sharing options...
m0nk Posted May 29, 2009 Author Share Posted May 29, 2009 I guess what I'm trying to ask is if there is something blatantly wrong with my code Ok so I decided to test it a different way by on the bottom line having it say this ;EOD echo "$body"; That way it outputs the the e-mail that I want it to send so I know if my code was working...it was a success, so my script is running fine, with the exception of the mail() function not working and thus not sending an e-mail out. Please, does anyone have any suggestions? As far as I can see my syntax for the mail() function is correct.... Thank you, m0nk. Quote Link to comment Share on other sites More sharing options...
elis Posted May 29, 2009 Share Posted May 29, 2009 I copied your code directly and it works for me. I've received the email upon loading the page. Check to see whether the use of mail() is enabled Quote Link to comment Share on other sites More sharing options...
m0nk Posted May 29, 2009 Author Share Posted May 29, 2009 Hey Elis thank you very much for taking the time out to test it!!!!!!!...and that is probably the best suggestion that I've heard so far (seriously). The problem is I am really new to php so I don't know how to enable the mail() function (which means it's most likely not enabled and you are right). So if you can point me in the right direction I would really appreciate it and if it works you would alleviate a ton of headaches for me. -m0nk Quote Link to comment Share on other sites More sharing options...
fullyscintilla Posted May 30, 2009 Share Posted May 30, 2009 php doesn't "Debug" in a program... php is a server side scripting language that gets parsed through the php engine. Thus in order to "debug" it you must run the php file through the browser. If error reporting is turned on.. it would blatently tell you that "function mail() doesn't exist" blah blah and so forth.. again PHP and dreamweaver... not the best of friends.. seriously drop dreamweaver man.. learn to code for real. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.