这个是我一直使用的php邮件类,里边有我的一个试用例子,一看就懂,很easy!
//$mail->AddAddress(" terryxiahui@yahoo.com.cn","dalilng");
//$mail->AddAddress(" xiahui@kaible.com","daling"); // 可选
// 附件,也可选加命名附件
解释index.php
<?php
//导入类文件
require("class.phpmailer.php");
require("class.phpmailer.php");
//声明类
$mail = new PHPMailer();
// 设置使用 SMTP
$mail->IsSMTP();
// 指定的 SMTP 服务器地址
$mail->Host = "61.172.255.101";
// 设置为安全验证方式
$mail->SMTPAuth = true;
// SMTP 发邮件人的用户名
$mail->Username = " service@kaible.com";
$mail->Username = " service@kaible.com";
// SMTP 密码
$mail->Password = "kaibleservice";
$mail->From = "
service@kaible.com";
$mail->FromName = "凯搏网";
$mail->AddAddress(" xiahui@kaible.com");
$mail->FromName = "凯搏网";
$mail->AddAddress(" xiahui@kaible.com");
//AddAddress函数格式为("收件地址","收件人")
//$mail->AddAddress(" terryxiahui@yahoo.com.cn","dalilng");
//$mail->AddAddress(" xiahui@kaible.com","daling"); // 可选
//可以回复的地址
//$mail->AddReplyTo(" xiahui@kaible.com", "TERRY2");
//$mail->AddReplyTo(" xiahui@kaible.com", "TERRY2");
// 50字折行
$mail->WordWrap = 50;
// 加附件
//$mail->AddAttachment("/var/tmp/file.tar.gz");
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
// 设置邮件格式为 HTML
$mail->IsHTML(true);
// 标题
$mail->Subject = "请迅速给我回邮件,好么";
// 内容
$mail->Body = '<B>邮件内容为空</B>';
// 附加内容
//$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
//$mail->Send()为邮件发送函数,不成功时执行if内容
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
?>