<?phpphp
//error_reporting(E_ALL);html
error_reporting(E_STRICT);ide
date_default_timezone_set('America/Toronto');server
//date_default_timezone_set(date_default_timezone_get());htm
include_once('../class.phpmailer.php');get
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded域名
$mail=new PHPMailer();it
$body=$mail->getFile('contents.html');io
$body=eregi_replace("[\]",'',$body);base64
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.126.com"; // SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "username@126.com"; // SMTP username 注意:普通郵件認證不須要加 @域名
$mail->Password = "password"; // SMTP password
$mail->From = "username@126.com";
$mail->FromName = "name";
$mail->CharSet = "GB2312"; // 這裏指定字符集!
$mail->Encoding = "base64";
$mail->AddAddress("username@126.com","name"); // 收件人郵箱和姓名
$mail->AddReplyTo("username@126.com","cgsir.com");
$mail->Subject = "PHPMailer Test Subject via smtp";
$mail->MsgHTML($body);
$mail->AddAttachment("p_w_picpaths/phpmailer.gif"); // p_w_upload
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>