<?php
require_once('../class.phpmailer.php');
$mail= new PHPMailer();
$body= "我終於發送郵件成功了!呵呵!goodboy xxxxxxx!<br/><a>http://news.qq.com/a/20111115/000792.htm?qq=0&ADUIN=594873950&ADSESSION=1321316731&ADTAG=CLIENT.QQ.3493_.0</a>";
//采用SMTP發送郵件
$mail->IsSMTP();
//郵件服務器
$mail->Host = "smtp.126.com";
$mail->SMTPDebug = 0;
//使用SMPT驗證
$mail->SMTPAuth = true;
//SMTP驗證的用戶名稱
$mail->Username = "[email protected]";
//SMTP驗證的秘密
$mail->Password = "password";
//設置編碼格式
$mail->CharSet = "utf-8";
//設置主題
$mail->Subject = "測試";
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
//設置發送者
$mail->SetFrom('[email protected]', 'test');
//采用html格式發送郵件
$mail->MsgHTML($body);
//接受者郵件名稱
$mail->AddAddress("[email protected]", "test");//發送郵件
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}