[PHP] 一个简单的php Emailer类 →→→→→进入此内容的聊天室

来自 , 2019-09-04, 写在 PHP, 查看 101 次.
URL http://www.code666.cn/view/8b838818
  1. import mx.events.EventDispatcher;
  2. import mx.utils.Delegate;
  3.  
  4. class Emailer {
  5.  
  6.     // required for EventDispatcher:
  7.     public var addEventListener:Function;
  8.     public var removeEventListener:Function;
  9.     private var dispatchEvent:Function;
  10.  
  11.     // use to communicate with php script
  12.     private var _lv:LoadVars;
  13.     // holds address of sender
  14.     private var _sentFrom:String;
  15.  
  16.     // constructor
  17.     public function Emailer() {    
  18.         EventDispatcher.initialize(this);
  19.         _lv = new LoadVars();
  20.     }
  21.  
  22.     //
  23.     private function dataReceived(dataxfer_ok:Boolean):Void {
  24.         // if some problem with loadVars transfer, pass back error=2
  25.         if (!dataxfer_ok) dispatchEvent({target:this, type:'mailSent', errorFlag:2});
  26.         // otherwise pass back error code returned from script
  27.         else dispatchEvent({target:this, type:'mailSent', errorFlag:Number(_lv["faultCode"])});
  28.     }
  29.  
  30.      // Use loadvars object to send data (set to call dataReceived when script returns data)
  31.     public function sendEmail(sub:String, fn:String, fe:String, msg:String, rep:String):Void {
  32.         // if user already sent from this address, show error msg
  33.         if (_sentFrom == fe) dataReceived(false);
  34.         // otherwise set up and send
  35.         else {
  36.             _sentFrom = fe;
  37.             // specify function to handle results, make scope = Emailer
  38.             _lv.onLoad = Delegate.create(this, dataReceived);
  39.             // set up properties of lv to items to be POSTed
  40.             _lv.subject = sub;
  41.             _lv.name = fn;
  42.             _lv.email = fe;
  43.             _lv.message = msg;
  44.             _lv.reply = rep;
  45.             // call script
  46.             _lv.sendAndLoad("sendemail.php", _lv, "POST");
  47.         }
  48.     }
  49. }
  50.  
  51.  

回复 "一个简单的php Emailer类"

这儿你可以回复上面这条便签

captcha