Guides & TutorialsSupport Tools TroubleshootingBad Request Error Importing Microsoft® Email

Bad Request Error Importing Microsoft® Email

Symptom

WHMCS fails to import emails using a Microsoft email service (for example, Microsoft Outlook® or Microsoft 365®).

Additionally, admins with the System email permission receive a POP3 Connection Error email with the following error detail:

Bad Request

Cause

The Redirect URI that you specified during app registration in the Microsoft Azure® Portal is invalid. It does not resolve to the callback handler file in your WHMCS installation.

This may be due to one of several causes:

  • The System URL setting in WHMCS begins with http://.
  • You have misconfigured WHMCS's Friendly URL settings.
  • The WHMCS installation URL changed after you registered the app.

Solution

To resolve this issue:

  1. Make certain that you have installed a valid SSL certificate on your website.
  2. In the WHMCS Admin Area, go to the General tab at Configuration > System Settings > General Settings.
  3. Update the WHMCS System URL setting to begin with https://.
  4. Click Save Changes.
  5. Re-synchronise your .htaccess file and confirm that Full Friendly Rewrite mode operates correctly. For more information, see Updating the .htaccess file.
  6. Edit the support department at the Configuration > System Settings > Support Departments.
  7. Under Mail Importing Configuration, copy the new Redirect URL value.
  8. Update your app registration in the Microsoft Azure Portal to use the new redirect URL. For more information, see Create Your Microsoft Azure Application.

The Redirect URL must use the following format, where example.com is your website and whmcs is the directory that stores WHMCS's files:

https://example.com/whmcs/admin/setup/mail/oauth2/callback