php - How do you send an email from within an AIR Desktop Application? -


i trying allow user send email within air desktop application. @ first tried:

navigatetourl(newurlrequest("mailto:someone@example.comsubject=hello&body=sometext"); 

but opens empty tab in default internet browser.

then tried use php file, uploaded on server. php code is:

<?php $to = ($_post['recipientemail']); $subject = ($_post['sendername']); $message = ($_post['sendermesssage']); $headers = "from: " . $_post['sendername'] . " <" . $_post['senderemail'] .     ">\n"; if(@mail($to, $subject, $message, $headers)) {     echo "answer=ok"; }  else  {     echo "answer=error"; } ?> 

and uploaded on following address: http://xespoofer.comxa.com/mail.php

the actionscript side is:

var myvars:urlvariables = new urlvariables(); myvars.sendername = settings.companyname; myvars.senderemail =string(settings.settingsxml.setting.@senderemail);; myvars.sendermesssage = string(settings.settingsxml.setting.@message); myvars.recipientemail = string(settings.settingsxml.setting.@email);  var myurl:urlrequest = new urlrequest("http://xespoofer.comxa.com/mail.php"); myurl.method = urlrequestmethod.post; myurl.data = myvars;  var myloader:urlloader = new urlloader(); myloader.dataformat = urlloaderdataformat.variables; myloader.load(myurl); 

the actionscript code runs when button clicked. problem nothing happens. email not sent. appreciated.

i suggest add listeners detect happening. tried (using hard coded strings, should replace use proper data):

var myvars:urlvariables = new urlvariables(); myvars.sendername = "name"; myvars.senderemail =string("email@email.com");; myvars.sendermesssage = string("message"); myvars.recipientemail = string("email2@email.com");  var myurl:urlrequest = new urlrequest("http://xespoofer.comxa.com/mail.php"); myurl.method = urlrequestmethod.post; myurl.data = myvars;  var myloader:urlloader = new urlloader(); myloader.dataformat = urlloaderdataformat.variables; myloader.addeventlistener(event.complete, completehandler); myloader.addeventlistener(progressevent.progress, progresshandler); myloader.addeventlistener(ioerrorevent.io_error, ioerrorhandler); myloader.load(myurl);  function completehandler(event:event):void {     trace("completehandler: ", urlloader(event.target).data.tostring()); }  function progresshandler(event:progressevent):void {     trace("progresshandler"); }  function ioerrorhandler(event:ioerrorevent):void {     trace("ioerrorhandler"); } 

and completehandler method outputs: "answer=ok". debug using real data , check if passing right values sendername, senderemail, sendermessage , recipientemail.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -