This class can be used in mass mailing mode. The test environment is linux, and sendmail must be installed in the system before it can be used.
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. "<$ senderEmail> ";
$ This-> replyTo = $ replyTo;
$ This-> subject = $ subject;
$ This-> message = $ message;
// Define the recipient
If (is_array ($ toList )){
$ This-> to = join ($ toList ,",");
} Else {
$ This-> to = $ toList;
}
// Define the CC list
If (is_array ($ ccList) & sizeof ($ ccList )){
$ This-> cc = join ($ ccList ,",");
} Elseif ($ ccList ){
$ This-> cc = $ ccList;
}
// Define the password CC list
If (is_array ($ bccList) & sizeof ($ bccList )){
$ This-> bcc = join ($ bccList ,",");
} Elseif ($ bccList ){
$ This-> bcc = $ bccList;
}
}
// Sending Function
// Use the mail () function in php to send an email
Function send (){
// Sender
$ This-> headers = "From:". $ this-> sender ."";
// Reply address
If ($ this-> replyTo ){
$ This-> headers. = "Reply-To:". $ this-> replyTo ."";
}
// CC
If ($ this-> cc ){
$ This-> headers. = "Cc:". $ this-> cc ."";
}
// Secretly CC
If ($ this-> bcc ){
$ This-> headers. = "Bcc:". $ this-> bcc ."";
}
Return mail ($ this-> to, $ this-> subject, $ this-> message, $ this-> headers); // return the result
}
}
}
?>
Note:
Parameter description
----------
-The following parameters are required: subject, message, senderName, senderEmail, and toList
-These parameters are optional: ccList, bccList, and replyTo.
-ToList, ccList, and bccList must be valid email addresses.