phpmailer做的一个可群发且发附件的mail

<?
require("class.phpmailer.php");

$mail = new PHPMailer();

$smtpserver = "smtp.126.com:25";

$smtpusermail = "wxq3327@126.com";
$smtpusername = "wangxq";
$smtpemailto = $_POST["to"];
$smtpuser = "wxq3327";
$smtppass = "wxq3327";

$uploaddir = 'c:/temp/';
$uploadfile = $uploaddir . basename($_FILES['attachfile']['name']);

$mailsubject = $_POST["name"]." send to you a mail 【" . $_POST["title"]."】";
$mailbody = $_POST["mail"];

 

$mail->IsSMTP(); // send via SMTP
$mail->Host = $smtpserver; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = $smtpuser; // SMTP username
$mail->Password = $smtppass; // SMTP password
$mail->CharSet = "UTF-8";


$mail->From = $smtpusermail;
$mail->FromName = $smtpusername;

$mailsto = explode(",",$smtpemailto);
for ($i=0;$i<count($mailsto);$i++)
{
 $mail->AddAddress($mailsto[$i]);
}


if (move_uploaded_file($_FILES['attachfile']['tmp_name'], $uploadfile)) {
    $mail->AddAttachment($uploadfile);
} else {
    echo "Possible file upload attack!\n";
}
$mail->WordWrap = 100; // set word wrap
$mail->IsHTML(true); // send as HTML

$mail->Subject = $mailsubject;
$mail->Body = $mailbody;
$mail->AltBody = $mailbody;

 

if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";
?>

posted on 2005-08-31 15:54 扭转乾坤 阅读(3329) 评论(1)  编辑  收藏 所属分类: 乱七八糟PHP相关

评论

# re: phpmailer做的一个可群发且发附件的mail 2010-08-27 15:22 我途求职

相当于同一封邮件有多个收件人吗  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 
<2005年8月>
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

导航

统计

常用链接

留言簿(2)

随笔分类(31)

随笔档案(30)

文章分类(32)

文章档案(33)

相册

PHP小站-首页

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜