Home > Backend Development > PHP Tutorial > Classes in PHP: Mass Email_PHP Tutorial

Classes in PHP: Mass Email_PHP Tutorial

WBOY
Release: 2016-07-20 11:04:08
Original
922 people have browsed it

This class can be used for mass email. The testing environment is Linux. The system needs to install sendmail to use it.

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 password carbon copy list
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 result
}
}
}
?>
Description:
Parameter Description
----------
- The following parameters are required: subject, message, senderName, senderEmail and toList
- These parameters are are optional: ccList, bccList and replyTo
- toList, ccList and bccList must be valid email addresses

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445243.htmlTechArticleThis class can be used for mass email. The testing environment is Linux. The system needs to install sendmail to use if ( ! defined( 'MAIL_CLASS_DEFINED' ) ) { define('MAIL_CLASS_DEFINED', 1 ); class...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template