Let the platform do the work

Troubleshooting Connecting Sugar to Gmail

Overview

Sugar instances may fail to connect to a Gmail account due to Google attempting to prevent suspicious activity. This issue can be encountered when any user is configuring a personal inbound email from their Emails module, when an admin is setting up the system email, or when an admin is configuring a Group or Bounce-Handling account via Admin > Inbound Email. The resolution steps are the same for each situation and will be discussed in this article.

Symptoms

When configuring email in Sugar and connecting to Gmail using Google basic authentication, you may be presented with an error message when attempting to test the settings. This may be an indication that Google is restricting Sugar from making the connection. 
setting-up-gmail
error

Additionally, in the sugarcrm.log in System Settings, you will see the following: 

    Tue Feb 28 14:43:12 2023[FATAL] SMTP -> ERROR: Password command failed. Reply: Username and 
Password not accepted. Learn more at
 https://support.google.com/mail/?p=BadCredentials mv11-20020a17090b198b00b002339195a47bsm8154320pjb.53 - gsmtp
Code: 535 Extended Code: 5.7.8
Tue Feb 28 14:43:12 2023[FATAL] MailerException - @(SmtpMailer.php:280 [6]) - Failed to connect to 
outbound SMTP Mail Server: The outbound mail server selected for the mail account you are using is 
invalid.  Check the settings or select a different mail server for the mail account.

Resolution

To resolve this issue, you should first confirm your email configuration by navigating to Gmail and confirming the email address and password work as expected. If the issue continues after the email settings are proven correct, you will need to enable 2-step verification and use an application password. The following sections provide instructions on how to perform these actions. 

Configuring Your Google Account

Use the following steps to set up 2-step verification and obtain an application password:

  1. Log into the affected Google account and navigate to https://myaccount.google.com.
  2. Click "Security" located on the left side of the page.  
    Google MyAccount
  3. Enable 2-step verification by selecting "2-Step Verification" in the Signing in to Google section.
    Select2Step
  4. Follow the prompts to enter and confirm a linked phone number. For more information, please view the 2-Step Authentication guide on Google's support site.  
  5. Once 2-step verification has been enabled, you may generate and use an application password. Please follow Google's step-by-step guide on their support site on how to do this. This application password will be used to connect to Sugar. You must use this password and not your usual account password.

Once you have set up 2-step verification and gotten an application password, please navigate back to your email settings in Sugar, use the new application password, and try connecting to Gmail again.