0 Replies Latest reply on Oct 27, 2009 2:54 PM by laxmidi

    Problem using HTTPService to Send Email-- Any suggestions???




      I'm trying to set up an HTTPService to send e-mail.


      My MXML is:


      <mx:Canvas id="emailStack">

      <mx:Panel height="401" width="400" layout="absolute" title="Contact us" x="20" y="100" styleName="crimePanel">


      <mx:Form x="9" y="10" width="360">

      <mx:FormItem label="Name :">

      <mx:TextInput id="senderName"/>



      <mx:FormItem label="Email :">

      <mx:TextInput id="senderEmail"/>



      <mx:FormItem label="Subject :">

      <mx:TextInput id="emailSubject"/>



      <mx:FormItem label="Message :">

      <mx:TextArea id="emailMessage" height="132" width="213" borderStyle="solid" borderThickness="1"/>






      <mx:Button label="Send" click="sendMail()" x="161" y="276"/>

      <mx:Label id="resultLabel" x="212" y="276"/>





      <mx:HTTPService id="emailService" url="php/mail.php" method="POST" resultFormat="xml" result="emailResult()" useProxy="false"/>

      <mx:EmailValidator id="mailValidator" source="{senderEmail}" property="text" requiredFieldError="Enter your email" required="true" />


      <mx:StringValidator id="nameValidator"  source="{senderName}" property="text" requiredFieldError="Enter your name" required="true"/>


      <mx:StringValidator id="emailValidator"  source="{emailMessage}" property="text" requiredFieldError="Enter your message" required="true"/>


      my functions are:


      import mx.events.ValidationResultEvent;

      import mx.controls.Alert;





      private function sendMail():void{

      var _senderName:String = senderName.text;

              var _senderEmail:String = senderEmail.text;

              var _emailMessage:String = emailMessage.text;

              var _emailSubject:String = emailSubject.text;



      var evValidMail:ValidationResultEvent = mailValidator.validate();

      var evValidName:ValidationResultEvent = nameValidator.validate();

      var evValidMessage : ValidationResultEvent = mailValidator.validate();




      if (evValidMail.type == ValidationResultEvent.VALID

      && evValidName.type == ValidationResultEvent.VALID

      && evValidMessage.type == ValidationResultEvent.VALID){

      emailService.send({senderName: _senderName, senderEmail:_senderEmail, emailSubject:_emailSubject, emailMessage: _emailMessage});




      resultLabel.text="There are Form errors";

      //resultLabel.setStyle("styleName", "invalid");








      private function emailResult():void{

                  Alert.show("Thank you for your submission");







      private function clearForm():void{








      my php is:



      $senderName = $_POST['senderName'];

      $senderEmail =  $_POST['senderEmail'];

      $sendToEmail = "joeblow@yahoo.com";

      $subject = $_POST['emailSubject'];

      $emailMessage = $_POST['emailMessage'];


      $recipient = "$sendToEmail";


      $headers = "From: $senderEmail ";

      $message = "From: $senderName, \nEmail Address: $senderEmail\nSubject: $subject\n\nMessage: $emailMessage";

      $message = StripSlashes($message);


      mail($recipient, $subject, $message, $headers)




      I'm on a Mac using MAMP with a localhost. The problem is that I'm getting the "Thank you for your submission" alert, but no e-mail is arriving in my yahoo mailbox. (joeblow@yahoo.com is not my real e-mail. I've changed it for this post).


      Am I doing something wrong with the HTTPService? I've tried putting the php file in the root directory with "http://...." and putting it in the debug folder without the full address. I've tried ever other option that I can think of.


      I adapted the above from RIA Codes' example www.riacodes.com/flex/create-an-email-form-in-flex-with-php/


      Any suggestions?


      Thank you!