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!
} |
阅读(1624) | 评论(0) | 转发(0) |