仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2437|回复: 19
打印 上一主题 下一主题

[学习教程] PHP教程之PHP中的类-邮件群发

[复制链接]
跳转到指定楼层
楼主
发表于 2015-2-16 00:25:46 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
也得学会了PHP。然后再学,见异思迁是最不可取的,狗熊掰玉米就是这个道理,如果经常中途放弃,只能是一无所获,还浪费了N多的时间和经历,得不偿失,最重要的是,你会被别人瞧不起。   

Linuxaid Wing

    本类可以用与于email的群发,测试的情况是linux,体系需求装置sendmail才干利用

<?php  

if ( ! defined( 'MAIL_CLASS_DEFINED' ) ) {  
       define('MAIL_CLASS_DEFINED', 1 );  

class email {  

      
       function email ( $subject, $message, $senderName, $senderEmail, $toList, $ccList=0, $bccList=0, $replyTo=0) {  
               $this->sender = $senderName . " <$senderEmail>";  
               $this->replyTo = $replyTo;  
               $this->subject = $subject;  
               $this->message = $message;  

               // 界说收件人  
               if ( is_array($toList) ) {  
                       $this->to = join( $toList, "," );  
               } else {  
                       $this->to = $toList;  
               }  

               // 界说抄送名单
               if ( is_array($ccList) && sizeof($ccList) ) {  
                       $this->cc = join( $ccList, "," );  
               } elseif ( $ccList ) {  
                       $this->cc = $ccList;  
               }  
                 
               // 界说暗码抄送名单  
               if ( is_array($bccList) && sizeof($bccList) ) {  
                       $this->bcc = join( $bccList, "," );  
               } elseif ( $bccList ) {  
                       $this->bcc = $bccList;  
               }  

       }  

       // 发送函数   
       // 使用php中的mail()函数发送email
      
       function send () {  
//发件人
                             $this->headers = "From: " . $this->sender . " ";   

               // 答复地址  
               if ( $this->replyTo ) {  
                       $this->headers .= "Reply-To: " . $this->replyTo . " ";  
               }  

               // 抄送  
               if ( $this->cc ) {  
                       $this->headers .= "Cc: " . $this->cc . " ";  
               }  

               // 奥密抄送
               if ( $this->bcc ) {  
                       $this->headers .= "Bcc: " . $this->bcc . " ";  
               }  
         
               return mail ( $this->to, $this->subject, $this->message, $this->headers ); //前往了局
       }  
}  


}  
?>

申明:


  参数申明  
  ----------  
  - 以下几个参数是必需的:subject, message, senderName, senderEmail 和 toList  
  - 这几个参数则是可选的:ccList, bccList 和 replyTo  
  - toList, ccList 和 bccList 必需是无效的email地址

  例如  
  -------  
  $m = new email ( "问候",             主题  
                   "你好吗?",            注释  
                   "Wing",                    发件人姓名  
                   "wing@linuxaid.com.cn",          发件人email  
                   array("aa@aa.com", "bb@bb.com”),  收件人  
                   "cc@cc.com"       抄送
                  );  

      print "邮件已发送,发送了局:" . $m->send();  
培训的第三阶段,开始接触MYSQL,设计数据库,学习PHP如何去连接MYSQL数据库。对于MYSQL,我并不陌生,因为学校开设了Linux系统的课程,对于数据库的操作。
沙发
 楼主| 发表于 2015-4-9 18:21:43 | 显示全部楼层
遇到出错的时候,我经常把错误信息直接复制到 google的搜索栏,一般情况都是能搜到结果的,不过有时候会搜出来一大片英文的出来,这时候就得过滤一下,吧中文的弄出来,挨着式方法。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-6-6 16:33

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表