PHP uses Zend_Mail to send emails (implementing the email password reset function)
Release: 2016-07-25 08:45:46
Original
1263 people have browsed it
- include_once 'conn/conn.php';
- require_once 'Zend/Mail.php'; //Call the file for sending emails
- require_once 'Zend/Mail/Transport/Smtp.php'; / /Call SMTP verification file
- $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){
- //Send password email
- $subject="Password Retrieval";
- $mailbody='Password retrieval successful. The new password for your account is '.$rnd;
- $envelope["from"]="cym3100@163.com";
- //$envelope="mrsoft8888@sohu.com"; //The one used for login defined by the online version Email
-
- /* smtp beta version sending email, using smtp as the server */
- $tr = new Zend_Mail_Transport_Smtp('192.168.1.247');
-
- $mail = new Zend_Mail();
- $mail->addTo( $email,'Get the user's new password');
- $mail->setFrom('cym3100@163.com','Tomorrow Technology's typical module program test email, change the user's registration password!');
- $mail-> setSubject($subject);
- $mail->setBodyHtml($mailbody);
- //$mail->send($tr);
-
- /* Online version sending email method*/
-
- /*$config = array('auth' => 'login',
- 'username' => 'mrsoft8888',
- 'password' => 'mrsoft8888'); //Define SMTP authentication parameters
- $transport = new Zend_Mail_Transport_Smtp(' smtp.sohu.com', $config); //Instantiate the object for verification
- $mail = new Zend_Mail('GBK'); //Instantiate the object for sending mail
- $mail->setBodyHtml($mailbody); / /Send email body
- $mail->setFrom($envelope, 'Tomorrow Technology Typical Module Program Test Email, Change User Registration Password! '); //Define the email address used to send emails
- $mail->addTo($email, 'Get the user's new password'); //Define the email address used to receive emails
- $mail->setSubject($subject); / /Define email subject
- $mail->send($transport); //Perform sending operation*/
-
- /* Online version sending email method*/
- if(false ==$mail->send($tr) ){
- $reback = '-1';
- }else{
- $reback = '1';
- }
- }else{
- $reback = '2';
- }
- }else{
- $reback = $sql;
- }
- echo $reback;
- ?>
Copy code
|
php, Zend
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
Latest Articles by Author
-
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