Class in PHP: Bulk mail _php Tutorial

Source: Internet
Author: User
This class can be used with the bulk of the email, testing the environment is Linux, the system needs to install SendMail to use

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 Recipients
if (Is_array ($toList)) {
$this->to = Join ($toList, ",");
} else {
$this->to = $toList;
}
Define CC List
if (Is_array ($ccList) && sizeof ($ccList)) {
$this-&GT;CC = Join ($ccList, ",");
} elseif ($ccList) {
$this->cc = $ccList;
}
Define a password cc list
if (Is_array ($bccList) && sizeof ($bccList)) {
$this-&GT;BCC = Join ($bccList, ",");
} elseif ($bccList) {
$this->bcc = $bccList;
}
}
Send function
Send email using the mail () function in PHP
function Send () {
Sender
$this->headers = "From:". $this->sender. " ";
Reply to Address
if ($this->replyto) {
$this->headers. = "Reply-to:". $this->replyto. " ";
}
Cc
if ($this->cc) {
$this->headers. = "Cc:". $this-&GT;CC. " ";
}
Secret CC
if ($this->bcc) {
$this->headers. = "BCC:". $this-&GT;BCC. " ";
}
Return mail ($this->to, $this->subject, $this->message, $this->headers); return results
}
}
}
?>
Description
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

http://www.bkjia.com/PHPjc/445243.html www.bkjia.com true http://www.bkjia.com/PHPjc/445243.html techarticle This class can be used with the bulk of the email, testing the environment is Linux, the system needs to install SendMail to use if (! defined (' mail_class_defined ')) {define (' Mail_class_ DEFINED ', 1); Class ...

  • 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.