建站极客
网络编程 PHP编程 正文
给多个地址发邮件的类
所属分类:
网络编程 / PHP编程
阅读数:
1236
收藏 0
赞 0
分享
<?php //////////////////////////////////////////////////////////// // EmailClass 0.5 // class for sending mail // // Paul Schreiber // php@paulschreiber.com // 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 // "foo@foobar.com", // sender's email // array("paul@foobar.com", "foo@bar.com"), // To: recipients // "paul@whereever.com" // 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 ); } } } ?>
两种php去除二维数组的重复项方法 这篇文章主要介绍了两种php去除二维数组的重复项方法,大家可以进行比较看哪一种更适合自己,需要的朋友可以参考下
评论 0
收藏 0
赞 0
分享
php实现网站留言板功能 这篇文章主要介绍了php实现网站留言板功能,主要仿照了畅言留言板和网易跟帖样式进行制作,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
评论 0
收藏 0
赞 0
分享
PHP实现HTML页面静态化的方法 这篇文章主要介绍了PHP实现HTML页面静态化的方法,分享了静态处理的方法,静态处理后的优势,并提供了多种静态的方法,感兴趣的小伙伴们可以参考一下
评论 0
收藏 0
赞 0
分享
php对文件夹进行相关操作(遍历、计算大小) 这篇文章主要介绍了php对文件夹进行相关操作,包括遍历并打印指定目录下所有文件和计算文件大小去空白,以及去重复值等,感兴趣的小伙伴们可以参考一下
评论 0
收藏 0
赞 0
分享
非常全面的php日期时间运算汇总 这篇文章主要整理了关于php日期时间运算相关内容,涉及知识点较为全面,感兴趣的小伙伴们可以参考一下
评论 0
收藏 0
赞 0
分享
php根据用户语言跳转相应网页 这篇文章主要介绍了php根据用户语言跳转相应网页的方法,主要区分国内国外,感兴趣的小伙伴们可以参考一下
评论 0
收藏 0
赞 0
分享
双冒号 ::在PHP中的使用情况 前几天在百度知道里面看到有人问PHP中双冒号::的用法,当时给他的回答比较简洁因为手机打字不大方便!今天突然想起来,所以在这里总结一下我遇到的双冒号::在PHP中使用的情况
评论 0
收藏 0
赞 0
分享
查看更多