Fixed User state "email_bounce": Cannot confirm email address without changing it

Steffen

Well-known member
Affected version
2.1.8
XenForo's bounce handler automatically disables accounts whose email has delivery problems. This is cool. Usually this means that the user should enter a different email address because his old address doesn't exist anymore.

But sometimes the errors leading to a disabled account were temporary and the user just wants to "re-confirm" his existing email address, hoping or knowing that the issue has been solved (we had such a case last week where the email provider mailbox.org temporarily responded with a permanent error code 550 to all delivery attempts). If a user account is in the "email_bounce" state then XenForo tells them to update their email. However, the email change form can be successfully (seemingly) submitted without changing the email address. No error is shown but no confirmation email is sent either. Users are stuck and don't know what to do. This has confused multiple of our users. Another such issue was reported just a few hours ago (german).

Would it make sense to let such users "re-confirm" their existing email address? That's what the following patch attempts to do:

Diff:
diff --git a/src/XF/Pub/Controller/Account.php b/src/XF/Pub/Controller/Account.php
index 70338f6c5..ff5c69b18 100644
--- a/src/XF/Pub/Controller/Account.php
+++ b/src/XF/Pub/Controller/Account.php
@@ -225,7 +225,7 @@ class Account extends AbstractController
             'password' => 'str'
         ]);

-        if ($input['email'] != $visitor->email)
+        if ($input['email'] != $visitor->email || $visitor->user_state === 'email_bounce')
         {
             /** @var \XF\Service\User\EmailChange $emailChange */
             $emailChange = $this->service('XF:User\EmailChange', $visitor, $input['email']);
diff --git a/src/XF/Service/User/EmailChange.php b/src/XF/Service/User/EmailChange.php
index 2d3a702aa..262f106d4 100644
--- a/src/XF/Service/User/EmailChange.php
+++ b/src/XF/Service/User/EmailChange.php
@@ -34,7 +34,7 @@ class EmailChange extends \XF\Service\AbstractService

     protected function changeEmail($email)
     {
-        if ($this->user->email !== $email)
+        if ($this->user->email !== $email || $this->user->user_state === 'email_bounce')
         {
             $this->changed = true;
             $this->oldEmail = $this->user->email;
@@ -109,7 +109,7 @@ class EmailChange extends \XF\Service\AbstractService

     protected function isConfirmationRequired()
     {
-        if (!$this->changed || !$this->app->options()->registrationSetup['emailConfirmation'])
+        if (!$this->app->options()->registrationSetup['emailConfirmation'])
         {
             return false;
         }
@@ -120,6 +120,11 @@ class EmailChange extends \XF\Service\AbstractService
             return false;
         }

+        if (!$this->changed && $user->user_state !== 'email_bounce')
+        {
+            return false;
+        }
+
         return true;
     }

Alternatively, I think XenForo could show some kind of error message when submitting the email change form doesn't have any effect (i.e. submitting the form didn't help the user leave the "email_bounce" state).

I think the first idea would be more user-friendly.
 
Last edited:
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.1.9).

Change log:
Allow users to reconfirm their existing email addresses if emails have previously bounced to it.
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom