We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4749
    • 623 Posts
    I may be blind, but I’ve done a forum and google search for forgotten password emails and couldn’t find anything. So, I’m happy to refer to something else if anyone knows of another topic. Anywho...

    I’m not a total noob to WLPE, but not an expert either. I’ve used it before and it’s worked fine, but I was hoping someone had an idea of where to look. I can login fine, logout, edit profiles and all that, but whenever I click "forgot password" I enter my email and then it acts as if it’s working and I get the message that reads- "Check your email for instructions on how to activate your new password." But, I never get a password. Has anyone experienced this before?

    I’m using the latest stable release 0963 and the latest release of WLPE.
      The MODx has you...
      Utah Web Design
      • 4749
      • 623 Posts
      Does anyone have any insight on this? I would really like to take care of this asap. I know I’m missing something, but I’m just not sure where to look. Can anyone point me to a spot that I can look for issues. Thanks.
        The MODx has you...
        Utah Web Design
        • 3749
        • 24,544 Posts
        I’m no WLPE expert and I’m just guessing here but maybe WLPE uses mail() and you’re using SMTP elsewhere?
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 4749
          • 623 Posts
          Thanks Bob. I ’ll check it out and report back.
            The MODx has you...
            Utah Web Design
            • 4749
            • 623 Posts
            Bob,
            WLPE uses PHPMailer. Here’s the section that’s used to reset the password:
            	
            	/**
            	 * ResetPassword
            	 * Sets a random password | random key in the web_users.cachepwd field,
            	 * then sends an email to the user with instructions and a URL to activate.
            	 *
            	 * @return void
            	 * @author Raymond Irving
            	 * @author Scotty Delicious
            	 */
            	function ResetPassword()
            	{
            		global $modx;
            		
            		$web_users = $modx->getFullTableName('web_users');
            		$web_user_attributes = $modx->getFullTableName('web_user_attributes');
            		
            		$email = $modx->db->escape(trim($_POST['email'])); // pixelchutes
            		if ( empty($email) ) return $this->FormatMessage($this->LanguageArray[0]); // pixelchutes        
                    $webpwdreminder_message = $modx->config['webpwdreminder_message'];
                    $emailsubject = $modx->config['emailsubject'];
            		$site_name = $modx->config['site_name'];
            		$emailsender = $modx->config['emailsender'];
            		
            		$findUser = "SELECT * FROM ".$web_user_attributes.", ".$web_users." WHERE `email`='".$email."' AND `internalKey`=".$web_users.".`id`";
            		$userInfo = $modx->db->query($findUser);
            		$limit = $modx->recordCount($userInfo);
            		
            		if ($limit == 1)
            		{
            			// Reset the password and fire off an email to the user
            			$newPassword = $this->GeneratePassword(10);
            			$newPasswordKey = $this->GeneratePassword(10);
            			$this->User = $modx->db->getRow($userInfo);
            			$insertNewPassword = "UPDATE ".$web_users." SET cachepwd='".$newPassword."|".$newPasswordKey."' WHERE id='".$this->User['internalKey']."'";
            			$setCachePassword = $modx->db->query($insertNewPassword);
            			
            			// build activation url
                        if($_SERVER['SERVER_PORT']!='80')
            			{
            				$url = $modx->config['server_protocol'].'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$modx->makeURL($modx->documentIdentifier,'',"&service=activate&userid=".$this->User['id']."&activationkey=".$newPasswordKey);
            			}
            			else
            			{
            				//$url = $modx->config['server_protocol'].'://'.$_SERVER['SERVER_NAME'].$modx->makeURL($modx->documentIdentifier,'',"&service=activate&userid=".$this->User['id']."&activationkey=".$newPasswordKey);
            				$url = $_SERVER['HTTP_REFERER']."&service=activate&userid=".$this->User['id']."&activationkey=".$newPasswordKey;
                        }
            			
            			$message = str_replace("[+uid+]", $this->User['username'], $webpwdreminder_message);
                        $message = str_replace("[+pwd+]", $newPassword, $message);
                        $message = str_replace("[+ufn+]", $this->User['fullname'], $message);
                        $message = str_replace("[+sname+]", $site_name, $message);
                        $message = str_replace("[+semail+]", $emailsender, $message);
                        $message = str_replace("[+surl+]", $url, $message);
            
            			$Reset = new PHPMailer();
            			$Reset->CharSet = $modx->config['modx_charset'];
            			$Reset->From = $emailsender;
            			$Reset->FromName = $site_name;
            			$Reset->Subject = $emailsubject;
            			$Reset->Body = $message;
            			$Reset->AddAddress($email, $this->User['fullname']);
            
            			if (!$Reset->Send())
            			{
            				return $this->FormatMessage($this->LanguageArray[12]);
            			}
            		}
            		else
            		{
            			return $this->FormatMessage($this->LanguageArray[14]);
            		}
            		$this->FormatMessage($this->LanguageArray[103]);
            		return;
            	}


            I hope that helps in some way. I just wish I was more adept at this stuff. Thanks for the help.

              The MODx has you...
              Utah Web Design
              • 3749
              • 24,544 Posts
              Well, my original theory is still viable I think.

              $Reset = new PHPMailer();


              This instantiates a new PHPmailer object, which I believe will default to using mail() unless explicitly set to use SMTP (and there’s no code there to do that). So other parts of the program (or other mailers you use) might be using SMTP while this function is using mail().

              The reason I thought of the mail() theory is that it’s the most common problem that causes no mail to be sent and yet triggers no error message.



                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting