给多个地址发邮件的类
2015-01-24信息快讯网
////////////////////////////////////////////////////////////
// EmailClass 0.5
// class for sending mail
//
// Paul Schreiber
// [email protected]
// http://paulschreiber.com/
//
// parameters
// ----------
// - subject, message, senderName, senderEmail and toList are required
// - ccList, bccList and replyTo are optional
// - toList, ccList and bccList can be strings or arrays of strings
// (those strings should be valid email addresses
//
// example
// -------
// $m = new email ( "hello there", // subject
// "how are you?", // message body
// "paul", // sender's name
// "[email protected]", // sender's email
// array("[email protected]", "[email protected]"), // To: recipients
// "[email protected]" // Cc: recipient
// );
//
// print "mail sent, result was" . $m->send();
//
//
//
if ( ! defined( 'MAIL_CLASS_DEFINED' ) ) {
define('MAIL_CLASS_DEFINED', 1 );
class email {
// the constructor!
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;
// set the To: recipient(s)
if ( is_array($toList) ) {
$this->to = join( $toList, "," );
} else {
$this->to = $toList;
}
// set the Cc: recipient(s)
if ( is_array($ccList) && sizeof($ccList) ) {
$this->cc = join( $ccList, "," );
} elseif ( $ccList ) {
$this->cc = $ccList;
}
// set the Bcc: recipient(s)
if ( is_array($bccList) && sizeof($bccList) ) {
$this->bcc = join( $bccList, "," );
} elseif ( $bccList ) {
$this->bcc = $bccList;
}
}
// send the message; this is actually just a wrapper for
// PHP's mail() function; heck, it's PHP's mail function done right :-)
// you could override this method to:
// (a) use sendmail directly
// (b) do SMTP with sockets
function send () {
// create the headers needed by PHP's mail() function
// sender
$this->headers = "From: " . $this->sender . "\n";
// reply-to address
if ( $this->replyTo ) {
$this->headers .= "Reply-To: " . $this->replyTo . "\n";
}
// Cc: recipient(s)
if ( $this->cc ) {
$this->headers .= "Cc: " . $this->cc . "\n";
}
// Bcc: recipient(s)
if ( $this->bcc ) {
$this->headers .= "Bcc: " . $this->bcc . "\n";
}
return mail ( $this->to, $this->subject, $this->message, $this->headers );
}
}
}
?>
基于HTTP长连接的"服务器推"技术的php 简易聊天室
php magic_quotes_gpc的一点认识与分析
轻松修复Discuz!数据库
php REMOTE_ADDR之获取访客IP的代码
Gregarius中文日期格式问题解决办法
mysql 中InnoDB和MyISAM的区别分析小结
php heredoc和phpwind的模板技术使用方法小结
require(),include(),require_once()和include_once()区别
Discuz! Passport 通行证整合
php下判断数组中是否存在相同的值array_unique
php str_replace的替换漏洞
set_include_path在win和linux下的区别
Bo-Blog专用的给Windows服务器的IIS Rewrite程序
海河写的 Discuz论坛帖子调用js的php代码
PHP5中的this,self和parent关键字详解教程
mysql4.1以上版本连接时出现Client does not support authentication protocol问题解决办法
Smarty+QUICKFORM小小演示
require(),include(),require_once()和include_once()的异同
php 中include()与require()的对比
用函数读出数据表内容放入二维数组
用PHP调用数据库的存贮过程!
php的header和asp中的redirect比较
PHP4在WinXP下IIS和Apache2服务器上的安装实例
PHP_Flame(Version:Progress)的原代码
用PHP实现标准的IP Whois查询
简单设置IIS配置PHP调试环境
用PHP生成PDF文件 with FPDF
WINDOWS 2000下使用ISAPI方式安装PHP
教你IIS6的PHP最佳配置方法
使用Apache的rewrite技术
新版百元变化更能防伪 收藏越稀缺越值钱
Quintus因病住院 “锋芝”探子同房共处半小时