Make WordPress Core

Opened 3 years ago

Last modified 9 days ago

#58917 new defect (bug)

Email Sending validation doesn't occur when password reset is sent from the Users page

Reported by: rajinsharwar's profile rajinsharwar Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch changes-requested
Focuses: Cc:

Description

Suppose my site isn't configured to send emails. So, when a user tries to reset his password from the public login page, he gets the below error.

https://prnt.sc/q_Z3IIC1f_dy

This is expected, but now, if I log in as an admin account, navigate under the Users page, and try to send the reset link for that user, I can see no validation error. The email doesn't get sent in real, but I can't see the error that my site isn't configured for sending emails.

https://prnt.sc/O9k_QpycwCfh

I think this type of behaviour is kind of confusing for users. We should show that validation error in the admin panel as well.

Change History (6)

#1 @audrasjb
3 years ago

  • Version trunk deleted

#2 @audrasjb
3 years ago

  • Component changed from Application Passwords to Users

This ticket was mentioned in PR #4921 on WordPress/wordpress-develop by @rajinsharwar.


3 years ago
#3

  • Keywords has-patch added

Checking if Email Sending is possible, and showing appropriate admin notices when a password reset is requested from the Users page.

Trac ticket: https://core.trac.wordpress.org/ticket/58917

#4 @rajinsharwar
3 years ago

I am now storing a transient flag "reset_password_email_failure" when the email sending fails, and then we check for this transient on the Users page to display the error message. The transient is set to expire in 60 seconds to ensure that the error message is only shown once after the email sending failure.

#5 @rajinsharwar
3 years ago

  • Keywords needs-testing added

#6 @ozgursar
9 days ago

  • Keywords changes-requested added; needs-testing removed

Patch Testing Report

Patch Tested: https://github.com/WordPress/wordpress-develop/pull/4921

Environment

  • WordPress: 7.0-beta2-61752-src
  • PHP: 8.2.29
  • Server: nginx/1.29.4
  • Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 145.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Code Snippets 3.9.5
    • Test Reports 1.2.1

Steps taken

  1. Add the following snippet to functions.php or via Code Snippets plugin to cause intentional email failure.
add_action( 'phpmailer_init', function( $phpmailer ) {
    $phpmailer->isSMTP();
    $phpmailer->Host = 'invalid.smtp.host';
    $phpmailer->Port = 587;
});
  1. Use /wp-login.php?action=lostpassword to remind a password for a user
  2. Confirm that the following message is displayed:
Error: The email could not be sent. Your site may not be correctly configured to send emails. Get support for resetting your password.
  1. In Dashboard Users > All Users page, click Send password reset of any user
  2. Confirm the following message is displayed:
Password reset links sent to 0 users.
  1. Apply the patch and test both /wp-login.php?action=lostpassword and dashboard password reminder screens
  2. ❌ Patch is failing.

Expected result

  • We expect to see the an error message displayed on the Users > All Users page similar to the one displayed on the login lost password screen.

Screenshots/Screencast with results

Error message on the /wp-login.php?action=lostpassword screen
https://i.imgur.com/y0oecx8.png

Admin dashboard Users > All Users before applying patch
https://i.imgur.com/eJVqUhP.png

Admin dashboard Users > All Users after applying patch
https://i.imgur.com/GMxcF0f.png

Note: See TracTickets for help on using tickets.