Telnet to a class that sends messages to multiple addresses

Source: Internet
Author: User
////////////////////////////////////////////////////////////
Emailclass 0.5
Class for sending mail
//
Paul Schreiber
Php@paulschreiber.com
http://paulschreiber.com/
//
Parameters
// ----------
-Subject, message, SenderName, Senderemail and toList are required
-CCList, Bcclist and replyTo are optional
-ToList, CCList and bcclist can be strings or arrays of strings
(Those strings should be valid email addresses
//
Example
// -------
$m = new Email ("Hello there",//Subject
"How is You?",//message body
"Paul",//sender ' s name
"Foo@foobar.com",//sender ' s email
Array ("paul@foobar.com", "foo@bar.com"),//To:recipients
"Paul@whereever.com"//Cc:recipient
// );
//
Print "mail sent, result was". $m->send ();
//
//
//
if (! defined (' mail_class_defined ')) {
Define (' mail_class_defined ', 1);
Class Email {
The constructor!
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;
Set the To:recipient (s)
if (Is_array ($toList)) {
$this->to = Join ($toList, ",");
} else {
$this->to = $toList;
}
Set the Cc:recipient (s)
if (Is_array ($ccList) && sizeof ($ccList)) {
$this-&GT;CC = Join ($ccList, ",");
} elseif ($ccList) {
$this->cc = $ccList;
}
Set the Bcc:recipient (s)
if (Is_array ($bccList) && sizeof ($bccList)) {
$this-&GT;BCC = Join ($bccList, ",");
} elseif ($bccList) {
$this->bcc = $bccList;
}
}
Send the message; This is actually just a wrapper for
PHP ' s mail () function; Heck, it's PHP ' s mail function done right:-)
You could override this method to:
(a) Use SendMail directly
(b) do SMTP with sockets
function Send () {
Create the headers needed by PHP ' s mail () function
Sender
$this->headers = "From:". $this->sender. "\ n";
Reply-to Address
if ($this->replyto) {
$this->headers. = "Reply-to:". $this->replyto. "\ n";
}
Cc:recipient (s)
if ($this->cc) {
$this->headers. = "Cc:". $this-&GT;CC. "\ n";
}
Bcc:recipient (s)
if ($this->bcc) {
$this->headers. = "BCC:". $this-&GT;BCC. "\ n";
}
Return mail ($this->to, $this->subject, $this->message, $this->headers);
}
}
}
?>

The above describes the telnet sent to multiple addresses to send e-mail messages, including the content of the Telnet email, I hope the PHP tutorial interested in a friend helpful.

  • Related Article

    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.