Home > Article > Backend Development > PHPMailer:Featured email transfer class for PHP_PHP教程
php(as the current mainstream development language)Mailer:Featured email transfer class for php(as the current mainstream development language)
php( As the current mainstream development language)Mailer is a very useful php(as the current mainstream development language) class for sending emails. It supports sending mail using smtp server, and also supports Sendmail, qmail, Postfix, Imail, Exchange, Mercury, Courier and other mail servers. The SMTP server also supports verification and multiple SMTP sending (but I’m not sure what it’s used for). Email sending can include multiple TO, CC, BCC and REPLY-TO, supports both text and HTML email formats, can automatically wrap lines, and supports Attachments and pictures in various formats, custom email headers and other basic email functions.
Since php(as the current mainstream development language) only contains one mail function, so php(as the current mainstream development language)Mailer is It is a great enhancement and I believe it can meet the needs of many people, haha. It mainly includes two class files: class.php (as the current mainstream development language) used to implement the function of sending emails mailer.php (as the current mainstream development language) and class.smtp.php implemented by smtp (as the current mainstream development language) . Then there are files that can implement various error outputs, as well as very detailed documentation. Software is distributed under the LGPL license.
is also very simple to use. You can understand it by looking at the following example:
require("class.php(as the current mainstream development language)mailer.php(as the current mainstream development language)");
$mail = new php(as the current mainstream development language)Mailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp1.site.com;smtp2.site.com"; // SMTP servers
$mail-> SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "jswan"; // SMTP username
$mail->Password = "secret"; // SMTP password
www.knowsky .com
$mail->From = "from@email.com";
$mail->FromName = "Mailer";
$mail->AddAddress("josh@site.com"," Josh Adams");
$mail->AddAddress("ellen@site.com"); // optional name
$mail->AddReplyTo("info@site.com","Information");
$mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
$mail- >AddAttachment("/tmp/image.jpg", "new.jpg");
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML body";
$mail->AltBody = "This is the text-only body";
if(!$mail->Send())
{
echo "Message was not sent
";
echo "Mailer Error: " . $mail->ErrorInfo ;
exit;
}
echo "Message has been sent";
For details, see php (as the current mainstream development language)Mailer's homepage: http://php(as the current mainstream development language)mailer.sourceforge.net/