Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1548619
  • 博文数量: 194
  • 博客积分: 6450
  • 博客等级: 准将
  • 技术积分: 2085
  • 用 户 组: 普通用户
  • 注册时间: 2005-06-06 13:39
文章分类

全部博文(194)

文章存档

2013年(38)

2012年(11)

2011年(1)

2010年(1)

2009年(4)

2008年(13)

2007年(18)

2006年(63)

2005年(45)

我的朋友

分类:

2005-12-06 18:01:31

Here's a complex example of sending an HTML email with SMTP authentication and attachments
来自:
sourceforge.net:

    
            
                 Mail Transport Agents

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

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

阅读(1062) | 评论(0) | 转发(0) |
0

上一篇:PHP SMTP 类

下一篇:ajax version 0.1 beta4 released

给主人留下些什么吧!~~