Main functional features and simple usage instructions of PHPMailer_PHP Tutorial

WBOY
Release: 2016-07-13 10:25:02
Original
773 people have browsed it

Supports email s/mime encrypted digital signatures
Supports multiple email TOs, CCs, BCCs and REPLY-TOs
Can work on any server platform, so you don’t have to worry about the WIN platform being unable to send emails
Support text/HTML format emails
Can embed images
Support email clients that do not support HTML reading
Powerful debugging function for sending emails
Customize email headers
Redundant SMTP server support
Supports 8bit, base64, binary, and quoted-printable encoding
Text automatic line wrapping
Supports multiple attachment sending function
Supports SMTP server verification function
In Sendmail, qmail, Postfix, Gmail, Imail, Exchange and other platforms have been successfully tested
The download file provided includes detailed documentation and examples, so don’t worry about getting started!
PHPMailer is very small, simple, convenient and fast

Usage of PHPMailer (here is using gmail smtp to send emails as an example, of course, sendmail pop and other other methods are also supported):
First go to http://phpmailer.worxware.com/ to download the latest version of the package
After the download is completed, find the two classes class.phpmailer.php and class.smtp.php and put them in your own directory!
Then create a new php file and name it here: phpmail.php
The content of phpmail.php is as follows:
I directly write the email sending module as a function postmail(). You can call this function directly when using it. , the function content is:

Program code

Copy code The code is as follows:

function postmail($to,$subject = "",$body = ""){
//$to represents the recipient address $subject represents the email title $body represents the email body
//error_reporting(E_ALL);
error_reporting(E_STRICT);
date_default_timezone_set("Asia/Shanghai");//Set the time zone Dongba District
require_once('class.phpmailer.php');
include("class.smtp.php");
$mail = new PHPMailer(); //new a PHPMailer object
$body = eregi_replace("[]",'',$body) ; //Perform necessary filtering of email content
$mail->CharSet ="UTF-8";//Set the email encoding, the default is ISO-8859-1, if you send Chinese, this must be set, otherwise it will be garbled
$mail->IsSMTP(); // Set up the SMTP service
$mail->SMTPDebug = 1; // 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // Enable SMTP authentication function
$mail->SMTPSecure = "ssl"; Host = "smtp.googlemail.com"; // SMTP server
$mail->Port = 465; // SMTP server port number
$mail->Username = "SMTP server username"; // SMTP server username
$mail->Password = "SMTP server password"; // SMTP server password
$mail->SetFrom('Sender address, such as admin@domain.com' , 'Sender's name');
$mail->AddReplyTo("Email reply address, such as admin@domain.com", "Name of the person who replied to the email");
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer! "; // optional, comment out and test
$mail->MsgHTML($body );
$address = $to;
$mail->AddAddress($address, "Recipient Name");
//$mail->AddAttachment("images/phpmailer.gif "); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
          echo "Message sent! Congratulations, the email was sent successfully! ";
}
}


http://www.bkjia.com/PHPjc/825237.html

truehttp: //www.bkjia.com/PHPjc/825237.htmlTechArticleSupport email s/mime encrypted digital signature. Support email multiple TOs, CCs, BCCs and REPLY-TOs to work. On any server platform, so don’t worry about the WIN platform being unable to send emails...
Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!