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