Class SaeMail

Description

SAE邮件class , 目前只支持SMTP

最大可发送1MB大小的邮件(含附件)

  1.  $mail new SaeMail();
  2.  $mail->setAttacharray'my_photo' => '照片的二进制数据' ) );
  3.  $ret $mail->quickSend'to@sina.cn' '邮件标题' '邮件内容' 'smtpaccount@gmail.com' 'password' );
  4.  
  5.  //发送失败时输出错误码和错误信息
  6.  if ($ret === false)
  7.          var_dump($mail->errno()$mail->errmsg());
  8.  
  9.  $mail->clean()// 重用此对象
  10.  $ret $mail->quickSend'to@sina.cn' '邮件标题' '邮件内容' 'smtpaccount@unknown.com' 'password' 'smtp.unknown.com' 25 )// 指定smtp和端口
  11.  
  12.  //发送失败时输出错误码和错误信息
  13.  if ($ret === false)
  14.          var_dump($mail->errno()$mail->errmsg());

错误码参考:

  • errno: 0 成功
  • errno: 3 参数错误
  • errno: 500 服务内部错误
  • errno: 999 未知错误
  • errno: 403 权限不足或超出配额

  • author: lijun

Located in /saemail.class.php (line 45)

SaeObject
   |
   --SaeMail
Method Summary
SaeMail __construct ([array $options = array()])
void clean ()
string errmsg ()
int errno ()
bool quickSend (string $to, string $subject, string $msgbody, string $smtp_user, string $smtp_pass, [string $smtp_host = ''], [string $smtp_port = 25], [string $smtp_tls = false])
bool send ()
bool setAttach (array $attach)
void setAuth (string $accesskey, string $secretkey)
bool setOpt (array $options)
Methods
Constructor __construct (line 103)

构造对象,此处options选项的设置和函数setOpt相同

SaeMail __construct ([array $options = array()])
  • array $options: 邮件发送参数,详细参数请参考SaeMail::setOpt($options)
clean (line 173)

用于重用实例化对象时,将上一次的相关数据清零

  • author: Lijun
  • access: public
void clean ()
errmsg (line 264)

取得错误信息

  • author: Lijun
  • access: public
string errmsg ()
errno (line 254)

取得错误码

  • author: Lijun
  • access: public
int errno ()
quickSend (line 196)

快速发送邮件

由于采用邮件队列发送,本函数返回成功时,只意味着邮件成功送到发送队列,并不等效于邮件已经成功发送

  • author: Lijun
bool quickSend (string $to, string $subject, string $msgbody, string $smtp_user, string $smtp_pass, [string $smtp_host = ''], [string $smtp_port = 25], [string $smtp_tls = false])
  • string $to: 要发送到的邮件地址,多个邮件地址之间用英文逗号","隔开
  • string $subject: 邮件标题
  • string $msgbody: 邮件内容
  • string $smtp_user: smtp用户名,必须为邮箱地址。注:和setOpt()中的smtp_user不同。
  • string $smtp_pass: smtp用户密码
  • string $smtp_host: smtp服务host,使用sina,gmail,163,265,netease,qq,sohu,yahoo的smtp时可不填
  • string $smtp_port: smtp服务端口,使用sina,gmail,163,265,netease,qq,sohu,yahoo的smtp时可不填
  • string $smtp_tls: smtp服务是否开启tls(如gmail),使用sina,gmail,163,265,netease,qq,sohu,yahoo的smtp时可不填
send (line 329)

发送邮件

  • author: Lijun
  • access: public
bool send ()
setAttach (line 296)

添加附件

附件和邮件正文的总大小不可超过1MB。

  • author: Lijun
  • access: public
bool setAttach (array $attach)
  • array $attach: , key为文件名称,附件类型由文件名后缀决定,value为文件内容;文件内容支持二进制
    支持的文件后缀:bmp,css,csv,gif,htm,html,jpeg,jpg,jpe,pdf,png,rss,text,txt,asc,diff,pot,tiff,tif,wbmp,ics,vcf
setAuth (line 278)

设置key

只有使用其他应用的key时才需要调用

  • author: Lijun
  • access: public
void setAuth (string $accesskey, string $secretkey)
  • string $accesskey
  • string $secretkey
setOpt (line 148)

设置发送参数,此处设置的参数只有使用send()方法发送才有效;quickSend()时将忽略此设置.

  • author: Lijun
  • access: public
bool setOpt (array $options)
  • array $options: 支持的Key如下:
        -----------------------------------------
        KEY        VALUE
        -----------------------------------------
        from        string (only one)
        -----------------------------------------
        to        string (多个用,分开)
        -----------------------------------------
        cc        string (多个用,分开)
        -----------------------------------------
        smtp_host    string
        -----------------------------------------
        smtp_port    port,default 25
        -----------------------------------------
        smtp_username    string
        -----------------------------------------
        smtp_password    string
        -----------------------------------------
        subject        string,最大长度256字节
        -----------------------------------------
        content        text
        -----------------------------------------
        content_type    "TEXT"|"HTML",default TEXT
        -----------------------------------------
        charset        default utf8
        -----------------------------------------
        tls        default false
        -----------------------------------------

Documentation generated on Wed, 11 Aug 2010 17:34:55 +0800 by phpDocumentor 1.4.3