PHPMailer is also a powerful email class
Main features of PHPMailer:
Supports email s/mime encrypted digital signature
Supports multiple email TOs, CCs, BCCs and REPLY-TOs
It can work on any server platform, so you don’t have to worry about the WIN platform being unable to send emails
Supports text/HTML format emails
Image can be embedded
Support for email clients that do not support HTML reading
Powerful debugging function for sending emails
Customized email header
Redundant SMTP server support
Supports 8bit, base64, binary, and quoted-printable encoding
Text automatically wraps
Supports multiple attachment sending function
Support SMTP server verification function
Successfully tested on Sendmail, qmail, Postfix, Gmail, Imail, Exchange and other platforms
The download file provided includes detailed documentation and examples, so you don’t have to worry about getting started!
PHPMailer is very small, simple, convenient and fast
The above information was translated from the phpmailer official website by Jiucool, please indicate when reprinting!
How to use PHPMailer (here is using gmail smtp to send emails as an example. Of course, sendmail pop and other other methods are also supported):
1. First go to http://phpmailer.worxware.com/ to download the latest version of the package
2. After the download is completed, find the two classes class.phpmailer.php and class.smtp.php and put them in your own directory!
3. Then create a new php file and name it: phpmail_jiucool.php
The content of phpmail_jiucool.php is as follows:
I directly wrote the email sending module as a function postmail_jiucool_com(). You can just call this function directly when using it. The function content is:
function postmail_jiucool_com($to,$subject = "",$body = ""){
//Author:Jiucool WebSite: http://www.jiucool.com
//$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(); //A new PHPMailer object comes out
$body = eregi_replace("[]",'',$body); //Perform necessary filtering on email content
$mail->CharSet ="UTF-8";//Set the mail encoding, the default is ISO-8859-1, if you send Chinese, this must be set, otherwise the code will be garbled
$mail->IsSMTP(); // Set to use SMTP service
$mail->SMTPDebug = 1; // Enable SMTP debugging
$mail->SMTPAuth = true; // Enable SMTP authentication function
$mail->SMTPSecure = "ssl"; $mail->SMTPSecure = "ssl"; // Security protocol
$mail->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's address, such as admin#jiucool.com #replace with @', 'Sender's name');
$mail->AddReplyTo("Email reply address, such as admin#jiucool.com #replace with @","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! - From www.jiucool.com"; // 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!";
}
}
Of course, there are more and more detailed configuration methods, and everyone is free to use them!
from: http://www.jiucool.com/phpmailer-php-email/