Linuxaid Wing
This class can be used with the bulk of the email, testing the environment is Linux, the system needs to install SendMail to use
<?php
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->CC = Join ($ccList, ",");
} elseif ($ccList) {
$this->cc = $ccList;
}
Define a cc list of passwords
if (Is_array ($bccList) && sizeof ($bccList)) {
$this->BCC = Join ($bccList, ",");
} elseif ($bccList) {
$this->bcc = $bccList;
}
}
Send function
Use the mail () function in PHP to send 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. " ";
}
Secret CC
if ($this->bcc) {
$this->headers. = "BCC:". $this->BCC. " ";
}
Return mail ($this->to, $this->subject, $this->message, $this->headers); return results
}
}
}
?>
Description
Parameter description
----------
-some of 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
For example
-------
$m = new Email ("Greetings", subject
"How are You?", the text
"Wing", Sender name
"wing@linuxaid.com.cn", sender email
Array ("aa@aa.com", "bb@bb.com"), Recipient
"Cc@cc.com" cc
);
Print "message sent, sending result:". $m->send ();