PHP class: mass mailing

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.