|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
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系统的课程,对于数据库的操作。 |
|