flex发送邮件

发布时间:2009-05-14 17:11:00 阅读:490次

flex借助php发送邮件,并附表单验证功能,表单如填写不正确,则邮件不能发送~~

mail.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()" layout="absolute" fontSize="14">
<mx:Script>
 <![CDATA[
  import mx.events.ValidationResultEvent;
  import mx.controls.Alert;
  import mx.validators.Validator;
  private var myValidators:Array;

  private function initApp():void {
   myValidators = [valid1, valid2,valid3];
  }

  private function sendmail():void{
   
   var errors:Array = Validator.validateAll(myValidators);
   if (errors.length == 0) {
     //Alert.show("Looks valid to me.", "SUCCESS"); 
     mailit.send();
      Alert.show("发送成功","alert");
    }

   else{
     Alert.show("请正确填写表单","alert");
    }
   }
 ]]>
</mx:Script>
 <mx:HTTPService id="mailit" url="mail/sendmail.php" method="POST" useProxy="false">
  <mx:request xmlns="">
   <receipt>{receipt.text}</receipt><mailfrom>{mailfrom.text}</mailfrom><mailbody>{mailbody.text}</mailbody>
  </mx:request>
 </mx:HTTPService>
 <mx:Iris id="iris" target="{panel}"></mx:Iris>
 <mx:Panel id="panel" x="350" y="132" width="464" height="408" layout="absolute" creationCompleteEffect="iris">
  <mx:Label id="label1" text="收件人" x="35" y="91"/>
  <mx:TextInput id="receipt" text="" x="113" y="89" />
  <mx:Button id="button1" label="发送邮件"  x="25" y="321" click="sendmail()" />
  <mx:Label x="35" y="45" text="发件人"/>
  <mx:TextInput x="113" y="43" text="" id="mailfrom" />
  <mx:TextArea x="113.5" y="133" width="306" height="175" text="" id="mailbody" />
  <mx:Label x="35" y="134" text="邮件内容"/>
  <mx:Label x="178" y="10" text="Flex发送邮件" width="105" fontSize="16" />
 </mx:Panel>
<mx:EmailValidator source="{receipt}" id="valid1" property="text" trigger="{button1}" triggerEvent="click"/>
<!--  valid="Alert.show('Email格式正确!');" -->
<mx:StringValidator id="valid2" source="{mailfrom}" property="text"
        tooShortError="字符串太短了,请输入最少3个字符. "
        tooLongError="字符串太长了,请输入最长20个字符. "
        minLength="3" maxLength="20"
        trigger="{button1}" triggerEvent="click"
        />  <!-- valid="Alert.show('字符串格式正确!');" -->
<mx:StringValidator id="valid3" source="{mailbody}" property="text"
        tooShortError="字符串太短了,请输入最少10个字符. "
        tooLongError="字符串太长了,请输入最长200个字符. "
        minLength="10" maxLength="200"
        trigger="{button1}" triggerEvent="click"
        />  <!-- valid="Alert.show('字符串格式正确!');" -->
</mx:Application>

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:flex发送邮件 出自老鄢博客 | 欢迎分享