Select to view content in your preferred language

Generate E-mail From Flex

632
2
03-08-2011 11:31 AM
PlanningLDS
Emerging Contributor
Hello All,
I am trying to create a widget that will accept user input in flex and then pass that info into a server side script which will generate an e-mail.  If anyone has experience trying something similar I'd love to hear about it.  I'm thinking about using PHP on the server side but have heard that could present security issues.  On the flex side I've seen examples using an HTTP Service call as well as some using URLLoader.  Any suggestions on best practices?

Flex HTTP Service
<fx:Declarations>
            
            <mx:HTTPService id="phpService"
                                 url="http://arcgis.allconet.org/mailVAR.php"
                                 useProxy="false"
                                 method="POST">
                              
                  <mx:request xmlns="">
                        <subject>{userName.text} + " " + {userContact.text}</subject>
                        <message>{userMessage.text}</message>
                  </mx:request>
            </mx:HTTPService>
            
      </fx:Declarations>


URLLoader
var mailRequest:URLRequest = new URLRequest("http://arcgis.allconet.org/mailVAR.php");
            var mailLoader:URLLoader = new URLLoader();
            var mailVariables:URLVariables = new URLVariables();
            
                  
            mailVariables.subject = userName.text + " " + userContact.text;
            mailVariables.message = userMessage.text;
            
            mailRequest.method = URLRequestMethod.POST;
            mailRequest.data = mailVariables;
            
            mailLoader.load(mailRequest);


PHP
<?php
$email = "someone@allconet.org";
$subject = $_POST['subject'];
$message = $_POST['message'];
mail($email, $subject, $message);
?>


Thanks for all input!

Greg
Tags (2)
0 Kudos
2 Replies
EjayLai
Deactivated User
I think it does the job and it's easy to implment.
0 Kudos
HessCorporation
Emerging Contributor
You can open a pre-populated e-mail window using URLRequest...

private var contactURL:URLRequest = new URLRequest("mailto:test@email.com&subject=e-mail subject&body=I'm sending an e-mail");


But this will only open a new e-mail window using the default mail provider, the user will have to click send for it to be triggered.

To automatically send an e-mail i think you'll have to use a server side script of some sort. Alternatively Adobe do offer MS exchange integration in ColdFusion but that might be a whole new level than you might not be looking for.
0 Kudos