11 Replies Latest reply on Jan 28, 2007 6:19 PM by Sketchsta

    mail Flash/PHP  doesnt work...

    Sketchsta Level 1
      Hi guys, im trying to make another mailer code using flash and php[, for a contact us page on a site im working on..
      The code i was using before used to work great, but now it doesnt work anymore and i have no idea why.. I am using it on a different server, but the server accepts php...

      anyway, i was soo frustrated that it doesnt work, i went ahead and made a new one... but this one doesnt work either... I need some help from you guys...

      I will kick my self sooo hard if it's something simple that im forgetting...

      heres the PHP code:
        • 1. Re: mail Flash/PHP  doesnt work...
          Sketchsta Level 1
          heres the Flash code..
          self explanatory... 4 frame timeline, each frame has different messages, depending on the response from PHP..

          by the way, after i get this to work im planning to add validation to the php, ( just incase anyone wonders why i have those if (conditions)

          • 2. Re: mail Flash/PHP  doesnt work...
            Peter Lorent Level 2
            Did you verify that the PHP scripts works 'stand alone'?
            • 3. Re: mail Flash/PHP  doesnt work...
              Sketchsta Level 1
              nope I haven't..

              how can I check it??
              • 4. Re: mail Flash/PHP  doesnt work...
                Peter Lorent Level 2
                Noticed:
                $toaddress='seul_kof@yahoo.com';
                Does the server allow sending mail to an 'external' address? Most servers need authentication to use the SMTP server to do that (spam...).
                • 5. Re: mail Flash/PHP  doesnt work...
                  Peter Lorent Level 2
                  >>how can I check it??
                  For instance by using an html page with a form.
                  • 6. Re: mail Flash/PHP  doesnt work...
                    Peter Lorent Level 2
                    Download this sample chapter from a book by David Powers:
                    http://www.friendsofed.com/samples/1590594665.pdf
                    • 7. Re: mail Flash/PHP  doesnt work...
                      Sketchsta Level 1
                      thanx LuigiL, yeah the server allows sending to external addresses.

                      i'll read that link you gave me, i really need to learn more PHP.
                      but for now this is just really kicking my butt, and i need it done by monday.

                      is there anything wrong that you can see?? in my AS or the PHP code??
                      • 8. Re: mail Flash/PHP  doesnt work...
                        Peter Lorent Level 2
                        Some errors in the PHP yes. Attached a script that I've tested and works (with another $toaddress of course).
                        Also, in the AS, trace the returned value (when you do a test movie) to see what happens:
                        dataReciever.onLoad = function() {
                        trace(this.response);


                        • 9. Re: mail Flash/PHP  doesnt work...
                          Sketchsta Level 1
                          Thanx LuigiL that works, i get the email sent, although the "number" field doesnt get sent.. any ideas why??

                          i tried:
                          if(mail($toaddress,$subject,$number,$message,"From: ".$name." <".$email.">")

                          but this way it didnt even send the email..

                          I've added trace to the code for the php you gave me, and im getting a "failed" response.. thats cuz im trying it locally right?
                          and when on the server, it sends the email, but the swf doesnt move to the " your message has been sent" frame.
                          • 10. Re: mail Flash/PHP  doesnt work...
                            Peter Lorent Level 2
                            Just as any function in any language the mail() function has a description (see http://www.php.net):
                            bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )

                            So, mail() returns a bool that indicates whether the mail was sent successfully or if it failed. I'm using a conditional in the script so you can check in Flash if the mail was sent successfully.
                            Now, in the function description of mail() you can see what parameters are expected. And your $number is treated as the message and your $message now messes up the fourth parameter. And the function fails.
                            You can send that number as a post var to the php script but you have to concatenate it there with the $message (see attached code).

                            The AS: whether you are testing locally or on the server doesn't matter. The mail should be sent successfully. But.. when testing locally you must provide the full path to the script on the server.

                            • 11. Re: mail Flash/PHP  doesnt work...
                              Sketchsta Level 1
                              Thanx for that, im getting the Number Field sent now.

                              This is what i meant, i REALLY need to learn more PHP. I didn't know the params, so i just assumed that if i add the $number before the $message, it will show up in the body of the email.. =)

                              and when i said i was testing it locally, i meant i was sending the fields to a LOCAL PHP, and was hetting "failed" but aslong as i was getting a response back from the PHP, i figured it worked.
                              anyway, i tested it again, on the server, and sure enough, im getting "passed".. only thing is, now my Flash movie wount listen to the if(this.response == "passed" or "failed") so now its just getting stuck on the second frame..

                              ehhh... it never seems to go easy for me... =(
                              i need to learn a whole lot more.

                              Thanx for all the help, verry much appreciated.. especially for clearing up the params for mail() thats a definate plus for my PHP future =)