使用phpMailer发送邮件
2012-10-16 13:30
169 查看
<!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 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/
相关文章推荐
- 在Thinkphp3.2 中使用PHPMailer 发送邮件
- 在使用phpmailer群发邮件时如何设置发送的时间间隔?
- 使用 PHPMailer 发送邮件
- PHP使用PHPMailer发送邮件
- 在thinkphp中使用phpmailer发送邮件
- ThinkPHP使用PHPMailer发送Email邮件汇总
- 使用 PHPMAILER 发送邮件实例应用
- PHP发送邮件类库PHPMailer的简单使用
- Thinkphp3.2中使用PHPMailer发送邮件
- PHP使用PHPMailer发送邮件的简单使用方法
- 使用 PHPMailer 发送邮件
- 使用phpmailer发送邮件
- PHP使用PHPmailer发送邮件方法
- PHP使用PHPMailer发送邮件的简单使用方法
- 使用 PHPMailer 发送邮件
- 使用 PHPMailer 发送邮件
- thinkphp使用PHPMailer发送邮件
- 在Thinkphp3.2 中使用PHPMailer 发送邮件
- thinkphp5使用phpmailer发送邮件
- 使用 PHPMailer 发送邮件