菜单

PHPMailer

2010年04月9日 - php

public function lostsave(){
$Dao=D(‘User’);
$username=$_POST[‘username’];
$em=$_POST[’em’];
$userinfo=$Dao->where(“username='{$username}’ and email=$em”)->find();
$email=$userinfo[’email’];   //邮箱
if(empty($userinfo)){
die(“<script>alert(‘用户名或邮箱错误,请重新输入!’);location.href=’user-lost-.html’;</script>”);
}elseif(empty($email)||$email==”){
die(“<script>alert(‘邮件发送失败,请检查您的用户名后重新发送,或者联系管理员!’);history.go(-1);</script>”);
}else {
srand((double)microtime()*1000000);
$rand_number= rand(100000,1000000);
$password=md5($rand_number);
$Dao->execute(“update user set password='{$password}’ where id={$userinfo[‘id’]}”);
$content=””;

$content=iconv(‘utf-8′,’gbk’,$content);
//发送邮件--------------------------------
require_once(‘Tour/Lib/ORG/class.phpmailer.php’);

$mail        =        new PHPMailer();
$mail->CharSet        =        “gbk”;
$mail->IsSMTP();
$mail->Host            =        “smtp.163.com”;           // SMTP服务器地址
$mail->Username        =        “”;           // 登录用户名
$mail->Password        =        “”;            //  登录密码
$mail->From = “”;                        //  发件人地址

$mail->SMTPAuth        =        true;                           // SMTP是否需要验证,现在STMP服务器基本上都需要验证
$mail->WordWrap   = 50;
$mail->IsHTML(true);                                 //是否支持html邮件,true 或false
$mail->FromName = iconv(‘utf-8′,’gbk’,”XX”);                    //   发件人名称
$mail->Subject    = iconv(‘utf-8′,’gbk’,”密码找回”);  //邮件标题
$mail->Body       = $content;
$mail->AddAddress(“{$email}”);
if($mail->Send()) {
echo “<script>alert(‘您的密码己发送到您的注册邮箱里,请及时查收!’);location.href=”</script>”;
}else {
echo $mail->ErrorInfo;
echo “<script>alert(‘邮件发送失败’);history.go(-1);</script>”;
}

}
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注