首页 > 开发 > PHP > 正文

用PHP调用数据库的存贮过程!

2024-05-04 23:00:43
字体:
来源:转载
供稿:网友
<?php  

////////////////////////////////////////////////////////////  
//   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 );  
        }  
}  


}  
?>  

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表