Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1100407
  • 博文数量: 165
  • 博客积分: 5957
  • 博客等级: 大校
  • 技术积分: 2015
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-24 15:04
文章分类

全部博文(165)

文章存档

2014年(10)

2013年(14)

2012年(9)

2011年(22)

2010年(17)

2009年(17)

2008年(26)

2007年(34)

2006年(16)

我的朋友

分类: LINUX

2010-11-15 10:26:02

1、下载PHPMailer_v5.1.tar.gz
2、解压后将class.phpmailer.php  class.pop3.php  class.smtp.php放入你指定的路径,供include或require。
3、具体mail程序

<?php
require_once('class.phpmailer.php');

$date=`/bin/date +%Y-%m-%d`;
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
  $mail->SMTPAuth = false; // enable SMTP authentication
  $mail->Host = "vip-smtp.vip.xyi.cn.alidc.net"; // sets the SMTP server
  $mail->Port = 25; // set the SMTP port for the GMAIL server
  $mail->Username = ""; // SMTP account username
  $mail->Password = ""; // SMTP account password

  $mail->AddAddress('xxx1@xxx.com');
  $mail->AddAddress('
xxx2@xxx.com'); 
  $mail->SetFrom('xxx3@xxx.com', '');
  $mail->CharSet = "GBK"; //important, title, content -- encode
  $mail->Subject = "[$date]xxx报告";
  $mail->MsgHTML(file_get_contents('/contents.html'));
  $mail->Send();
  echo "Message Sent OK

\n";
} catch (phpmailerException $e) {
  echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
  echo $e->getMessage(); //Boring error messages from anything else!
}


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

上一篇:表单处理

下一篇:随机颜色的产生与应用

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