Phpmailer code to send email and implement password retrieval function

Source: Internet
Author: User
Tags word wrap
Use Phpmailer to send mail, and realize forgot password find add function code, the need for friends, you can refer to the next.

To achieve the following functions: 1, according to the mail back link into the Reset Password operation page. Only one week, one effective 2, reset password (you can also send password directly login)

1. Generate mail to retrieve mail

     Hello!
According to your on [". Date (' y-m-d h:m:s '). "], this message will guide you to reset ["]. $account. "] Password for the account. If you confirm that the "Reset password" request is submitted by you yourself, please click here to complete the reset operation (this link is only one week, once valid). If the above link is not clickable, you can also copy the following link, paste it into your browser's address bar, and then press "enter" to open the Reset secret Question page to set up a new secret question and answer: {$url} If you have not submitted a "Reset password" request at these points, it is possible that your secret question is a The case has been compromised and a malicious user is trying to steal your account! "; SendMail ($subject, $body, $address); function SendMail ($subject, $body, $address) {$mail = new Phpmailer (); $mail->charset = ' utf-8 '; $mail->ishtml (TRUE); Set the message format to HTML $mail->issendmail (); Use Linux sendmail to send mail $mail->host = web_site_host; Specify main and Backup server $mail->smtpauth = true; Set to secure authentication method $mail->setlanguage (' en ', path_class. ' /phpmailer/language/'); $mail->from = Mail_sender; $mail->fromname = "service"; $mail->addaddress ($address); Recipient address $mail->wordwrap = 50; Set word wrap toCharacters $mail->subject = $subject; $mail->body = Daddslashes ($body, 1); $result = $mail->send (); if (! $result) {echo $mail->errorinfo; } $mail->smtpclose (); return $result; }//Mail link validity check function resetpass ($mapping, $form, & $request, & $response) {$use _id = $request GetParameter (' u '); $user = $this->delegate->getuserinfo_byid ($use _id); $o _mail = $user [' email ']; $o _account = $user [' account ']; $auth = $request->getparameter (' auth '); $auth = Authcode ($auth, ' DECODE ', ' safeemail '); $n _auth = $use _id. $o _account. $o _mail; $a = false; if ($n _auth = = $auth) {$a = true; } $form->setedituser ($user); if ($a) {//valid return $mapping->findforwardconfig (' resetpwd '); }}?>

class.phpmailer.php Line 332 recursive call, mass mailing

 
      $value) {                  $this->addmutieaddress ($value);              }          } else{              $this->addaddress ($arrAddress);          }      }  ? >

The first use of Gmail failed Smtpsecure=ssl. Phpmailer sending HTML style missing resolution: cannot use a style with a path Use

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.