返回顶部

收藏

一个简单的php email类

更多
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");
        }
    }
} 

标签:email,邮件发送,php

收藏

0人收藏

支持

0

反对

0

相关聚客文章
  1. Christopher Pitt 发表 2016-04-22 16:00:00 What is SparkPost?
  2. Christopher Pitt 发表 2016-04-22 16:00:00 What is SparkPost?
  3. wkii 发表 2013-05-30 14:35:38 Yii deleteByAttributs 用法,慎用Dao的delete
  4. phpor 发表 2016-06-09 08:34:36 关于PHP之“Allowed memory size exhausted”
  5. ideawu 发表 2016-06-23 07:53:56 PHP过滤掉Emoji表情字符
  6. 东东东 发表 2015-04-10 03:49:58 laravel session的使用,填一下坑
  7. yeseng 发表 2016-07-14 16:00:42 NeutrinoEK来袭:爱拍网遭敲诈者病毒挂马
  8. annhe 发表 2016-07-21 05:41:43 iTop导出中文PDF
  9. rungobier 发表 2016-08-04 02:44:54 IPS Community Suite PHP远程代码执行漏洞分析(CVE-2016-6174)
  10. Wern Ancheta 发表 2016-08-11 16:00:28 A Pokemon Crash Course on CouchDB
  11. gouki 发表 2016-08-27 23:32:00 wordpress 升级遇到问题
  12. gouki 发表 2016-09-07 10:19:00 去除内容中所有的多余的空格和空行

发表评论