473,396 Members | 1,940 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,396 software developers and data experts.

Why can't I get this mail() script to work

I have a flash template with a contact page when you put all the information in the fields and click send it says sent like everything works. After that I check my mail and there is nothing there. I have tested the webserver it is php compatible. I also created a mini test string and was able to send and recieve a test email using that small string. I'll post the action script in flash first then the php code. Id appreciate someone telling me what I'm doing wrong.

Thanks

Heres the action script in flash
Expand|Select|Wrap|Line Numbers
  1.  
  2. function clearField()
  3. {
  4.     txtField1.text = label1;
  5.     txtField2.text = label2;
  6.     txtField3.text = label3;
  7.     txtField4.text = label4;
  8.     txtField5.text = label5;
  9.     Selection.setFocus("_focus");
  10. } // End of the function
  11. label1 = "";
  12. label2 = "";
  13. label3 = "";
  14. label4 = "";
  15. label5 = "Message:";
  16. countField = 5;
  17. clearField();
  18. var arrayLabel = new Array();
  19. for (i = 1; i < countField + 1; i++)
  20. {
  21.     txtField = this["txtField" + i];
  22.     txtField.index = i;
  23.     arrayLabel[i] = this["label" + i];
  24.     txtField.tabIndex = i;
  25.     txtField.onSetFocus = function ()
  26.     {
  27.         if (this.text == arrayLabel[this.index])
  28.         {
  29.             this.text = "";
  30.         } // end if
  31.     };
  32.     txtField.onKillFocus = function ()
  33.     {
  34.         if (this.text == "")
  35.         {
  36.             this.text = arrayLabel[this.index];
  37.         } // end if
  38.     };
  39. } // end of for
  40. btnClear.onRollOver = function ()
  41. {
  42.     this.gotoAndPlay("over");
  43. };
  44. btnClear.onRollOut = btnClear.onReleaseOutside = function ()
  45. {
  46.     this.gotoAndPlay("out");
  47. };
  48. btnClear.onRelease = function ()
  49. {
  50.     clearField();
  51. };
  52. btnSubmit.onRollOver = function ()
  53. {
  54.     this.gotoAndPlay("over");
  55. };
  56. btnSubmit.onRollOut = btnSubmit.onReleaseOutside = function ()
  57. {
  58.     this.gotoAndPlay("out");
  59. };
  60. btnSubmit.onRelease = function ()
  61. {
  62.     if (_parent.contactform.txtField1.text == label1 || _parent.contactform.txtField2.text == label2 || _parent.contactform.txtField3.text == label3 || _parent.contactform.txtField4.text == label4 || _parent.contactform.txtField5.text == label5)
  63.     {
  64.         gotoAndStop(3);
  65.     }
  66.     else
  67.     {
  68.         _parent.contactform.loadVariables("email.php", "POST");
  69.         gotoAndStop(2);
  70.     } // end else if
  71. };
  72. stop ();
  73.  
Heres the php script
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //Type the receiever's e-mail address
  3. $emailAddress = "brian@sbsitedesigns.com";
  4. //Type your Site Name
  5. $siteName = "SBSiteDesigns.com";
  6.  
  7. $contact_name = $_POST['name'];
  8. $contact_email = $_POST['email'];
  9. $contact_subject = $_POST['subject'];
  10. $contact_message = $_POST['message'];
  11.  
  12. if( $contact_name == true ) {
  13.     $sender = $contact_email;
  14.     $receiver = $emailAddress;
  15.     $client_ip = $_SERVER['REMOTE_ADDR'];
  16.  
  17.     $email_body = "The Name Of The Sender: $contact_name \nEmail: $sender \n\nSubject: $contact_subject
  18. \n\nMessage: \n\n$contact_message \n\nIP ADDRESS: $client_ip \n\n$siteName";
  19.  
  20.     $emailAutoReply = "Hi $contact_name, \n\nWe have just received your E-Mail. We will get
  21. in touch in a few days. Thank you!  \n\n$siteName ";
  22.  
  23.     $extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
  24.     $autoReply = "From: $receiver\r\n" . "Reply-To: $receiver \r\n" . "X-Mailer: PHP/" . phpversion();
  25.  
  26.     mail( $sender, "Auto Reply: $contact_subject", $emailAutoReply, $autoReply );
  27.  
  28.     if( mail( $receiver, "New E-Mail - $contact_subject", $email_body, $extra ) ) {
  29.         echo "success=yes";
  30.     } else {
  31.         echo "success=no";
  32.     }
  33. }
  34. ?>
  35.  
Thanks in advance
Aug 19 '10 #1
12 2611
TheServant
1,168 Expert 1GB
Just run this in a new php file to see if your mail is configured correctly: (remember to put your email in the $to, and also check your spam box)
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  $to = "recipient@example.com";
  3.  $subject = "Email test";
  4.  $body = "Testtesttest";
  5.  if (mail($to, $subject, $body)) {
  6.    echo("<p>Message successfully sent!</p>");
  7.   } else {
  8.    echo("<p>Message delivery failed...</p>");
  9.   }
  10.  ?>
Aug 20 '10 #2
Thats very similar to the "mini" script I wrote and tested with, but I ran yours anyways. Same thing it sent, and I received, so it has to be something in the mail.PHP script itself.
Thanks for your replay
Aug 20 '10 #3
TheServant
1,168 Expert 1GB
Try:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //Type the receiever's e-mail address
  3. $emailAddress = "brian@sbsitedesigns.com";
  4. //Type your Site Name
  5. $siteName = "SBSiteDesigns.com";
  6.  
  7. $contact_name = $_POST['name'];
  8. $contact_email = $_POST['email'];
  9. $contact_subject = $_POST['subject'];
  10. $contact_message = $_POST['message'];
  11.  
  12.     /* -- Test -- */
  13. echo "Contact Name: $contact_name< br/>";
  14. echo "Contact Email: $contact_email< br/>";
  15. echo "Contact Subject: $contact_subject< br/>";
  16. echo "Contact Message: $contact_message< br/>< br/>";
  17.  
  18. if( $contact_name == true ) {
  19.     $sender = $contact_email;
  20.     $receiver = $emailAddress;
  21.     $client_ip = $_SERVER['REMOTE_ADDR'];
  22.  
  23.     $email_body = "The Name Of The Sender: $contact_name \nEmail: $sender \n\nSubject: $contact_subject
  24. \n\nMessage: \n\n$contact_message \n\nIP ADDRESS: $client_ip \n\n$siteName";
  25.  
  26.     $emailAutoReply = "Hi $contact_name, \n\nWe have just received your E-Mail. We will get
  27. in touch in a few days. Thank you!  \n\n$siteName ";
  28.  
  29.     $extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
  30.     $autoReply = "From: $receiver\r\n" . "Reply-To: $receiver \r\n" . "X-Mailer: PHP/" . phpversion();
  31.  
  32.     /* -- Test -- */
  33.     echo "Email Body: $email_body< br/>";
  34.     echo "Auto Reply Email: $emailAutoReply< br/>";
  35.     echo "Extra: $extra< br/>";
  36.     echo "Auto Reply: $autoReply< br/>";
  37.  
  38.  
  39.  
  40.  
  41.     mail( $sender, "Auto Reply: $contact_subject", $emailAutoReply, $autoReply );
  42.  
  43.     if( mail( $receiver, "New E-Mail - $contact_subject", $email_body, $extra ) ) {
  44.         echo "success=yes";
  45.     } else {
  46.         echo "success=no";
  47.     }
  48. }
  49. ?>
I have just put in some echo's at some points to see if your variables are what you expect. I am hoping it's something easy like $_POST not being sent correctly.

Out of interest, does your Auto Reply mail work? Or are both emails not working?
Aug 20 '10 #4
Well its not as easy as I'd hoped. It's down right frustrating! That code you gave me didn't work. To answer your question (first thanks for your help!) I'm not receiving the auto reply or the notification e-mail
Aug 20 '10 #5
TheServant
1,168 Expert 1GB
What do you mean it didn't work? There was no output?

If so, then I'm going to guess it's how you're calling the script.
Aug 22 '10 #6
The last script that you gave me didn't send me a reply or notification. I have checked and rechecked the actionscript and I'm at a loss. I guess I'll have to just use another script. Thanks for your help.
Aug 23 '10 #7
TheServant
1,168 Expert 1GB
I put in a bunch of echo's to see if it was everything you expected. Did none of those print?
Aug 23 '10 #8
Namik
3
What I did to the actionScript is add a getURL to the end of it and pointed it to the email.php page.

This is the result I got.

Contact Name: < br/>Contact Email: < br/>Contact Subject: < br/>Contact Message: < br/>< br/>

So basically nothing.

I tested the email PHP which you had posted earlier and it was all fine. Recieved email.

The only problem I think is the actionScript posting the variables to the email.php

Can you help mate?
Sep 15 '10 #9
Markus
6,050 Expert 4TB
You should turn on error-reporting.

Expand|Select|Wrap|Line Numbers
  1. // At the very top of your code
  2. error_reporting(-1);
  3. ini_set('display_errors', 1);
  4.  
Sep 16 '10 #10
Namik
3
Where would I see these errors?

I think it's the flas ActionScript posting to the PHP which is the problem.

I can't get around how to fix it though.
Sep 16 '10 #11
Namik
3
I fixed the problem. Apparently in the AS line 69 there was a function which didn't allow the sending of data gotoAndstop(2);

so I added a this function so it would send the data and when it received confirmation from the server it would stop.

Expand|Select|Wrap|Line Numbers
  1. _parent.contactform.loadVariables("email.php", this, "POST");
  2.         this.onData = function() {
  3.             gotoAndStop(2);
  4.         };
Sep 25 '10 #12
Hi Namik,
Can you please let me know how you get it to work? Cuz i tried copy the part you added and i was never able to get the button submit to activate. If you could post up the entire code that is working for you that would be very helpful.
thanks
john
Feb 1 '11 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Web Master | last post by:
Hi, I am having a little issue with Jacks Form mail php script. I have installed it and configured the form to get it to work, but for some bizarre reason I have 2 issues I can't seem to debug....
3
by: trend5 | last post by:
I have a simple mail script designed to use from command line. I want create a simple web interface to use this script as remotely hosted webscript, from webhost. The script contains two files-...
3
by: Steve Richter | last post by:
How does the following javascript work? After the first script runs the variables "sGeobytesCity", "sGeobytesRegion" and "sGeobytesCountry" contain values that have been set somehow by the...
2
by: steve | last post by:
I'm trying to create a PHP script to send mail to a list of addresses. I'm sending mail okay, because the messages arrive in an account that I can check, but messages to a known bad address aren't...
6
by: Chuck W. | last post by:
So I have a very simple mail script just to send a quick 'n dirty notification of a form posting -- it goes like this: $message = $_POST . "\", first_name = \"". $_POST . "\",last_name = \""....
4
by: shror | last post by:
dear all, i have started learning php 2 weeks ago and i have wrote my first script for mail sender and the script takes all my data and move to the thanks page but the problem is that the mails...
13
chunk1978
by: chunk1978 | last post by:
hi there... i would like to know if anyone could look at my mail script and tell me if there is anything clearly wrong, or missing... <?php $to = $_POST; $subject = 'test'; $random_hash =...
2
by: DVH | last post by:
Hi, I've a script that sends mail from my site. I've included a regexp which should return 403 forbidden if you try to hijack it and send to another address. How can I test to make sure it...
0
by: Joe Demeny | last post by:
I am looking for a python web form to mail script for a public web site - could you recommend one? -- Joe Demeny
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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 project—planning, coding, testing,...

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.