PHP 中的类:邮件群发_PHP
程序员文章站
2023-12-24 18:25:33
...
本类可以用与于email的群发,测试的环境是linux,系统需要安装sendmail才能使用
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 . " ";
$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();
转载:http://nczzf.51.net
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 . " ";
$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();
转载:http://nczzf.51.net
推荐阅读
-
html标签如何使用php中的变量
-
Apache中RewriteCond规则参数的详细介绍_PHP教程
-
PHP能将下拉列表的值赋给数据库中date类型的字段吗解决方案
-
PHP汉字转拼音的类 UTF8版
-
【PHP】array_walk_recursive ― 对数组中的每个成员递归地施用用户函数
-
PHP中的排序函数sort、asort、rsort、krsort、ksort区别分析_PHP
-
如何将一个PHP数组有格式的写入文件中
-
操作Oracle的php类_PHP
-
Symfony2实现在doctrine中内置数据的方法,symfony2doctrine_PHP教程
-
PHP中通过HTTP_USER_AGENT判断是否为手机移动终端的函数代码_PHP