PHPMailer:Featured email transfer class for PHP

WBOY
Release: 2016-06-01 14:28:06
Original
1114 people have browsed it

phpMailer:Featured email transfer class for PHP
PHPMailer 是一个很有用的 PHP 发送邮件的类。它支持使用 smtp 服务器发送邮件,同时支持 Sendmail, qmail, Postfix, Imail, Exchange, Mercury, Courier 等邮件服务器。SMTP服务器的话还支持验证,多SMTP发送(不过不太清楚有什么用).邮件发送可以包括多个TO, CC, BCC and REPLY-TO,支持text和HTML两种邮件格式,可以自动换行,支持各种格式的附件及图片,自定义邮件头等基本的邮件功能。

  由于 PHP 中只包含了一个 mail 函数,所以 PHPMailer 是对其很大的增强,相信是可以满足很多人的需求的,呵呵。其主要包括两个类文件:用于实现发送邮件功能的 class.phpmailer.php 和 smtp 实现的 class.smtp.php 。然后还有可以实现多种错误输出的文件,以及很详细的文档。软件发布遵循 LGPL 协议。

使用也很简单,看下面的例子就明白了:

require("class.phpmailer.php");

$mail = new PHPMailer();

$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.cncms.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";


详见PHPMailer的主页:http://phpmailer.sourceforge.net/

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