Home > Backend Development > PHP Tutorial > PHP uses Zend_Mail to send emails (implementing the email password reset function)

PHP uses Zend_Mail to send emails (implementing the email password reset function)

WBOY
Release: 2016-07-25 08:45:46
Original
1263 people have browsed it
  1. include_once 'conn/conn.php';
  2. require_once 'Zend/Mail.php'; //Call the file for sending emails
  3. require_once 'Zend/Mail/Transport/Smtp.php'; / /Call SMTP verification file
  4. $reback = '0';
  5. $name = $_GET['foundname'];
  6. $question = $_GET['question'];
  7. $answer = $_GET['answer'];
  8. $sql = "select email from tb_member where name = '".$name."' and question = '".$question."' and answer = '".$answer."'";
  9. $email = $conne- >getFields($sql,0);
  10. if($email != ''){
  11. $rnd = rand(1000,time());
  12. $sql = "update tb_member set password = '".md5($ rnd)."' where name = '".$name."' and question = '".$question."' and answer = '".$answer."'";
  13. $tmpnum = $conne->uidRst ($sql);
  14. if($tmpnum >= 1){
  15. //Send password email
  16. $subject="Password Retrieval";
  17. $mailbody='Password retrieval successful. The new password for your account is '.$rnd;
  18. $envelope["from"]="cym3100@163.com";
  19. //$envelope="mrsoft8888@sohu.com"; //The one used for login defined by the online version Email
  20. /* smtp beta version sending email, using smtp as the server */
  21. $tr = new Zend_Mail_Transport_Smtp('192.168.1.247');
  22. $mail = new Zend_Mail();
  23. $mail->addTo( $email,'Get the user's new password');
  24. $mail->setFrom('cym3100@163.com','Tomorrow Technology's typical module program test email, change the user's registration password!');
  25. $mail-> setSubject($subject);
  26. $mail->setBodyHtml($mailbody);
  27. //$mail->send($tr);
  28. /* Online version sending email method*/
  29. /*$config = array('auth' => 'login',
  30. 'username' => 'mrsoft8888',
  31. 'password' => 'mrsoft8888'); //Define SMTP authentication parameters
  32. $transport = new Zend_Mail_Transport_Smtp(' smtp.sohu.com', $config); //Instantiate the object for verification
  33. $mail = new Zend_Mail('GBK'); //Instantiate the object for sending mail
  34. $mail->setBodyHtml($mailbody); / /Send email body
  35. $mail->setFrom($envelope, 'Tomorrow Technology Typical Module Program Test Email, Change User Registration Password! '); //Define the email address used to send emails
  36. $mail->addTo($email, 'Get the user's new password'); //Define the email address used to receive emails
  37. $mail->setSubject($subject); / /Define email subject
  38. $mail->send($transport); //Perform sending operation*/
  39. /* Online version sending email method*/
  40. if(false ==$mail->send($tr) ){
  41. $reback = '-1';
  42. }else{
  43. $reback = '1';
  44. }
  45. }else{
  46. $reback = '2';
  47. }
  48. }else{
  49. $reback = $sql;
  50. }
  51. echo $reback;
  52. ?>
Copy code

php, Zend


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template