PHP uses Zend_mail to send mail (reset password function for mail)

Source: Internet
Author: User
  1. Include_once ' conn/conn.php ';
  2. Require_once ' zend/mail.php '; Call the file that sent the message
  3. Require_once ' zend/mail/transport/smtp.php '; Invoking SMTP validation files
  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 Mail
  16. $subject = "Recover password";
  17. $mailbody = ' Password recovered successfully. The new password for your account is '. $rnd;
  18. $envelope ["From"]= "cym3100@163.com";
  19. $envelope = "mrsoft8888@sohu.com"; Network Edition defines the mailbox used for login
  20. /* SMTP beta send mail mode, use SMTP as Server */
  21. $TR = new Zend_mail_transport_smtp (' 192.168.1.247 ');
  22. $mail = new Zend_mail ();
  23. $mail->addto ($email, ' Get user new password ');
  24. $mail->setfrom (' cym3100@163.com ', ' Tomorrow Technology typical module program test mailbox, modify the user registration password! ');
  25. $mail->setsubject ($subject);
  26. $mail->setbodyhtml ($mailbody);
  27. $mail->send ($TR);
  28. /* E-mail method */
  29. /* $config = Array (' auth ' = ' login ',
  30. ' Username ' = ' mrsoft8888 ',
  31. ' Password ' = ' mrsoft8888 '); Defining authentication parameters for SMTP
  32. $transport = new Zend_mail_transport_smtp (' smtp.sohu.com ', $config); The object of the case test certificate
  33. $mail = new Zend_mail (' GBK '); Instantiating a Send mail object
  34. $mail->setbodyhtml ($mailbody); Send Message body
  35. $mail->setfrom ($envelope, ' Tomorrow Technology typical module program test mailbox, modify the user registration password! '); Define the mailboxes used for sending messages
  36. $mail->addto ($email, ' Get user new password '); Define a receive mailbox for a message
  37. $mail->setsubject ($subject); Defining Message Topics
  38. $mail->send ($transport); Perform a send operation */
  39. /* E-mail 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
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.