<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHPMailer - Mail() basic test</title>
</head>
<body>
<?php
require_once $_SERVER [DOCUMENT_ROOT] . '/lib/PHPMailer/class.phpmailer.php';
$mail = new PHPMailer (); // defaults to using php "mail()"
$mail->Host = "smtp.qq.com"; //设置SMTP服务器
$mail->Hostname = "smtp.qq.com";
$mail->IsSMTP (); // telling the class to use SMTP
$mail->SMTPAuth = true; // SMTP服务器是否需要验证
//$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent
//$mail->SMTPSecure = "ssl";
$mail->Port = 25; //设置SMTP服务器端口
$mail->Username = "1024114660"; //邮箱账号
$mail->Password = "*******************"; //邮箱密码
$mail->SetFrom ( '1024114660@qq.com', '杜晓孔' );
$mail->AddReplyTo ( "duxiaokong@sina.com", "First Last" );
$mail->AddReplyTo ( "1024114660@qq.com", "First Last" );
$address = "***************@qq.com";
$mail->AddAddress ( $address, "MR.du" );
$mail->Subject = "主题部分";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; //可选项,当不支持显示html显示
$body = file_get_contents ( 'http://www.baidu.com' );
//$body = eregi_replace ( "[\]", '', $body );
$mail->MsgHTML ( $body );
$mail->AddAttachment ( "images/001.jpg", '附件名1.jpg' ); // 附件,不能上传相同的附件
$mail->AddAttachment ( "images/002.jpg", '附件名.jpg' ); // 第二个参数为附件显示的名字,如果没有则默认使用文件名
if (! $mail->Send ()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
官方网站: http://phpmailer.worxware.com/
phpMailer下载地址:
http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHPMailer - Mail() basic test</title>
</head>
<body>
<?php
require_once $_SERVER [DOCUMENT_ROOT] . '/lib/PHPMailer/class.phpmailer.php';
$mail = new PHPMailer (); // defaults to using php "mail()"
$mail->Host = "smtp.qq.com"; //设置SMTP服务器
$mail->Hostname = "smtp.qq.com";
$mail->IsSMTP (); // telling the class to use SMTP
$mail->SMTPAuth = true; // SMTP服务器是否需要验证
//$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent
//$mail->SMTPSecure = "ssl";
$mail->Port = 25; //设置SMTP服务器端口
$mail->Username = "1024114660"; //邮箱账号
$mail->Password = "*******************"; //邮箱密码
$mail->SetFrom ( '1024114660@qq.com', '杜晓孔' );
$mail->AddReplyTo ( "duxiaokong@sina.com", "First Last" );
$mail->AddReplyTo ( "1024114660@qq.com", "First Last" );
$address = "***************@qq.com";
$mail->AddAddress ( $address, "MR.du" );
$mail->Subject = "主题部分";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; //可选项,当不支持显示html显示
$body = file_get_contents ( 'http://www.baidu.com' );
//$body = eregi_replace ( "[\]", '', $body );
$mail->MsgHTML ( $body );
$mail->AddAttachment ( "images/001.jpg", '附件名1.jpg' ); // 附件,不能上传相同的附件
$mail->AddAttachment ( "images/002.jpg", '附件名.jpg' ); // 第二个参数为附件显示的名字,如果没有则默认使用文件名
if (! $mail->Send ()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
官方网站: http://phpmailer.worxware.com/
phpMailer下载地址:
http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/