php email类,实现基础邮件发送示例

前端之家收集整理的这篇文章主要介绍了php email类,实现基础邮件发送示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
对一个简单的PHP email类,实现了最基础的邮件发送功能感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

/**
 * 一个简单的PHP email类,实现了最基础的邮件发送功能
 *
 * @param 
 * @arrange 网: 512Pic.com
 **/
import mx.events.EventDispatcher;
import mx.utils.Delegate;
class Emailer {
 // required for EventDispatcher:
 public var addEventListener:Function;
 public var removeEventListener:Function;
 private var dispatchEvent:Function;
 // use to communicate with PHP script
 private var _lv:LoadVars;
 // holds address of sender
 private var _sentFrom:String;
 // constructor
 public function Emailer() {    
  EventDispatcher.initialize(this);
  _lv = new LoadVars();
 }
 // 
 private function dataReceived(dataxfer_ok:Boolean):Void {
  // if some problem with loadVars transfer,pass back error=2
  if (!dataxfer_ok) dispatchEvent({target:this,type:'mailSent',errorFlag:2});
  // otherwise pass back error code returned from script
  else dispatchEvent({target:this,errorFlag:Number(_lv["faultCode"])});
 }
  // Use loadvars object to send data (set to call dataReceived when script returns data)
 public function sendEmail(sub:String,fn:String,fe:String,msg:String,rep:String):Void {
  // if user already sent from this address,show error msg
  if (_sentFrom == fe) dataReceived(false);
  // otherwise set up and send
  else {
   _sentFrom = fe;
   // specify function to handle results,make scope = Emailer
   _lv.onLoad = Delegate.create(this,dataReceived);
   // set up properties of lv to items to be POSTed
   _lv.subject = sub;
   _lv.name = fn;
   _lv.email = fe;
   _lv.message = msg;
   _lv.reply = rep;
   // call script
   _lv.sendAndLoad("sendemail.PHP",_lv,"POST");
  }
 }
} 
/***   来自编程之家 jb51.cc(jb51.cc)   ***/
原文链接:https://www.f2er.com/php/528582.html

猜你在找的PHP相关文章