Class for sending emails to multiple addresses .? PhpEmailClass0.5classforsendingmailPaulSchreiberphp@paulschreiber.compaulschreiber.com
//////////////////////////////////////// ////////////////////
// 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 shocould 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
// PHP's mail () function; heck, it's PHP's mail function done right :-)
// You cocould override this method:
// (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://www.bkjia.com/PHPjc/315941.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/315941.htmlTechArticle? Php /////////////////////////////////////// //////////// EmailClass 0.5 // class for sending mail //// Paul Schreiber/php@paulschreiber.com // http://paulschreiber.com //...