Classes in PHP-bulk mail

Source: Internet
Author: User

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-&GT;CC = Join ($ccList, ",");
} elseif ($ccList) {
$this->cc = $ccList;
}

Define a cc list of passwords
if (Is_array ($bccList) && sizeof ($bccList)) {
$this-&GT;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-&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
----------
-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 ();



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.