用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - php代码库

一个简单的php Emailer类

2014-12-03 作者: php源代码大全举报

[php]代码库

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, type:'mailSent', 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");
        }
    }
} 



网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...