×ðÁú¿­Ê±¹ÙÍøµÇ¼

thinkphpÔõÑùʵÏÖÓÊÏäÐÞ¸ÄÃÜÂë

Ò»¡¢»ù´¡×¼±¸

ÔÚʹÓÃthinkphp¿ò¼ÜϵÄÓÊÏäÐÞ¸ÄÃÜÂ빦Ч֮ǰ£¬ÎÒÃÇÐèÒªÍê³ÉÒÔÏÂ×¼±¸ÊÂÇ飺

×°ÖÃPHPMailer²å¼þ

PHPMailerÊÇÒ»¸ö¾­µäµÄÓʼþ·¢ËͲå¼þ£¬¿ÉÒÔ¾ÙÐÐÓʼþÊÕ·¢¡¢¸½¼þ·¢Ë͵ȲÙ×÷£¬ÎÒÃÇÐèÒª½«Æä×°Öõ½thinkphp¿ò¼ÜÖÐʹÓá£

ÔÚconfig.phpÎļþÖÐÉèÖÃÓÊÏäÐÅÏ¢

ÎÒÃÇÐèÒªÔÚconfig.phpÎļþÖÐÉèÖÃÏìÓ¦ÓÊÏäÐÅÏ¢£¬°üÀ¨SMTPЧÀÍÆ÷¡¢ÓÊÏäÓû§Ãû¡¢ÃÜÂëµÈ¡£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

±àдÓÊÏäÐÞ¸ÄÃÜÂëÒ³Ãæ

ÎÒÃÇÐèÒª½«ÓÊÏäÐÞ¸ÄÃÜÂëÏà¹ØµÄÒ³Ãæչʾ³öÀ´£¬²¢Í¨¹ý¿ØÖÆÆ÷µÄŲÓÃʵÏÖÓÊÏäÃÜÂëÐ޸ġ£

¶þ¡¢±àдÓÊÏäÐÞ¸ÄÃÜÂë¿ØÖÆÆ÷

½¨Éè¿ØÖÆÆ÷

ÔÚthinkphp¿ò¼ÜÖУ¬ÎÒÃÇÐèÒªÏȽ¨ÉèÒ»¸ö¿ØÖÆÆ÷Îļþ£¬ÓÃÓÚ¿ØÖÆÓÊÏäÃÜÂëÐ޸ĵÄÏà¹ØÐж¯¡£

ÉèÖÿØÖÆÆ÷µÄÊôÐÔ

ÎÒÃÇÐèÒªÉèÖÿØÖÆÆ÷µÄÊôÐÔ£¬°üÀ¨Ä¿½ñ¿ØÖÆÆ÷µÄÃüÃû¿Õ¼ä¡¢ËùÊôÄ £¿é¡¢½á¹¹ÎļþµÈ¡£

±àдÃÜÂëÐÞ¸ÄÒªÁì

ÎÒÃÇÐèÒª±àдһ¸öÃûΪmodifyPasswordµÄÒªÁ죬ͨ¹ýÒªÁìÖеIJÎÊý»ñÈ¡Óû§µÄÄ¿½ñÃÜÂëºÍÐÂÃÜÂ룬Ȼºóͨ¹ýPHPMailer²å¼þ·¢ËÍÓʼþ¾ÙÐÐÃÜÂëÐ޸ġ£

ʾÀý´úÂëÈçÏ£º

<?php
namespace app\index\controller;
use think\Controller;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

class Email extends Controller{
    protected $module='index';
    protected $layout='public/layout';
    protected $namespace='app\index\controller';
    
    public function modifyPassword($email,$oldPassword,$newPassword){
        //н¨PHPMailer¹¤¾ß
        $mail=new PHPMailer(true);
        
        //ÉèÖÃSMTPЧÀÍÆ÷ÐÅÏ¢
        $mail->isSMTP();
        $mail->SMTPAuth=true;
        $mail->SMTPSecure='ssl';
        $$mail->Host='smtp.gmail.com';
        $mail->Port=465;
        $mail->Username='xxxx@gmail.com';
        $mail->Password='xxxx';
        
        //ÉèÖÃÓʼþÄÚÈÝ
        $mail->setFrom('xxxx@gmail.com','ÖÎÀíÔ±');
        $mail->addAddress($email);
        $mail->Subject='ÐÞ¸ÄÃÜÂë';
        $mail->Body="ÄúµÄÄ¿½ñÃÜÂëÊÇ{$oldPassword}£¬ÐÂÃÜÂëÊÇ{$newPassword}"£»
        
        //·¢ËÍÓʼþ
        if(!$mail->send()){
            echo 'Óʼþ·¢ËÍʧ°Ü£º' . $mail->ErrorInfo;
        }else{
            echo 'Óʼþ·¢ËÍÀÖ³É';
        }
    }
}

µÇ¼ºó¸´ÖÆ

Èý¡¢Íê³ÉÓʼþÐÞ¸ÄÃÜÂ빦Ч

ÔÚÍê³ÉÉÏÊö¿ØÖÆÆ÷µÄ±àдºó£¬ÎÒÃÇÐèÒª½¨ÉèÏìÓ¦µÄ·ÓÉ£¬½«ÓʼþÐÞ¸ÄÃÜÂëµÄÏà¹ØÒ³ÃæºÍ¿ØÖÆÆ÷ÅþÁ¬ÆðÀ´¡£

»á¼ûÓÊÏäÐÞ¸ÄÃÜÂëÒ³Ãæºó£¬ÐèÒªÊäÈëÄ¿½ñÃÜÂëºÍÐÂÃÜÂ룬Ȼºó½«Êý¾Ý´«Èë¿ØÖÆÆ÷ÖУ¬¾ÙÐÐÓʼþ·¢ËͲÙ×÷£¬¼´¿ÉʵÏÖÓÊÏäÃÜÂëÐ޸Ĺ¦Ð§¡£

×îºó£¬ÐèҪעÖصÄÊÇ£¬ÓʼþÐÞ¸ÄÃÜÂ빦Чʮ·ÖÃô¸ÐÇÒÒªº¦£¬Òò´ËÔÚ¿ª·¢Àú³ÌÖÐÐèÒªÔöÇ¿¶ÔÒªº¦´úÂëµÄ±£ÃÜÐÔ£¬ÒÔÈ·±£³ÌÐòµÄÇå¾²ÐÔ¡£

ÒÔÉϾÍÊÇthinkphpÔõÑùʵÏÖÓÊÏäÐÞ¸ÄÃÜÂëµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ