php利用Zend_Mail发送邮件(实现邮件重设密码功能)
-
include_once 'conn/conn.php';
- require_once 'Zend/Mail.php'; //调用发送邮件的文件
- require_once 'Zend/Mail/Transport/Smtp.php'; //调用SMTP验证文件
- $reback = '0';
- $name = $_GET['foundname'];
- $question = $_GET['question'];
- $answer = $_GET['answer'];
- $sql = "select email from tb_member where name = '".$name."' and question = '".$question."' and answer = '".$answer."'";
- $email = $conne->getFields($sql,0);
- if($email != ''){
- $rnd = rand(1000,time());
- $sql = "update tb_member set password = '".md5($rnd)."' where name = '".$name."' and question = '".$question."' and answer = '".$answer."'";
- $tmpnum = $conne->uidRst($sql);
- if($tmpnum >= 1){
- //发送密码邮件
- $subject="找回密码";
- $mailbody='密码找回成功。您帐号的新密码是'.$rnd;
- $envelope["from"]="cym3100@163.com";
- //$envelope="mrsoft8888@sohu.com"; //网络版定义登录使用的邮箱
-
- /* smtp测试版发送邮件方式,使用smtp作为服务器*/
- $tr = new Zend_Mail_Transport_Smtp('192.168.1.247');
-
- $mail = new Zend_Mail();
- $mail->addTo($email,'获取用户新密码');
- $mail->setFrom('cym3100@163.com','明日科技典型模块程序测试邮箱,修改用户注册密码!');
- $mail->setSubject($subject);
- $mail->setBodyHtml($mailbody);
- //$mail->send($tr);
-
- /* 网络版发送邮件方法 */
-
- /*$config = array('auth' => 'login',
- 'username' => 'mrsoft8888',
- 'password' => 'mrsoft8888'); //定义SMTP的验证参数
- $transport = new Zend_Mail_Transport_Smtp('smtp.sohu.com', $config); //实例化验证的对象
- $mail = new Zend_Mail('GBK'); //实例化发送邮件对象
- $mail->setBodyHtml($mailbody); //发送邮件主体
- $mail->setFrom($envelope, '明日科技典型模块程序测试邮箱,修改用户注册密码!'); //定义邮件发送使用的邮箱
- $mail->addTo($email, '获取用户新密码'); //定义邮件的接收邮箱
- $mail->setSubject($subject); //定义邮件主题
- $mail->send($transport); //执行发送操作*/
-
- /* 网络版发送邮件方法 */
- if(false ==$mail->send($tr) ){
- $reback = '-1';
- }else{
- $reback = '1';
- }
- }else{
- $reback = '2';
- }
- }else{
- $reback = $sql;
- }
- echo $reback;
- ?>
复制代码
|
php, Zend
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31