SMTP Failed authentication - 535

Hello,

My Sentry does not send emails. And throws a 535 error on the test email:

{“error”:"(535, ‘5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials f6sm10254029wrr.15 - gsmtp’)"}

config.yaml:

###############
# Mail Server #
###############

mail.backend: ‘smtp’ # Use dummy if you want to disable email entirely
mail.host: ‘smtp.gmail.com
mail.port: 587
mail.username: ‘sentry@mydomain.com’
mail.password: ‘********’
mail.use-tls: true
# The email address to send on behalf of
mail.from: ‘sentry@mydomain.com’

#If you’d like to configure email replies, enable this.
mail.enable-replies: true

# When email-replies are enabled, this value is used in the Reply-To header
mail.reply-hostname: ‘sentry.mydomain.com

# If you’re using mailgun for inbound mail, set your API key and configure a
# route to forward to /api/hooks/mailgun/inbound/
# Also don’t forget to set mail.enable-replies: true above.
# mail.mailgun-api-key: ‘’

I have checked the username and password and they are both correct. I have enabled less secure apps in the gmail account.

Something I find strange in the Mail Settings is the Username in the dashboard:

However, looking at the request, it seems everything is in order:

{“mailFrom":"sentry@mydomain.com,“mailHost”:“smtp.gmail.com”,“mailPassword”:true,“mailListNamespace”:“localhost”,“mailPort”:587,“mailUsername”:"sentry@mydomain.com",“testMailEmail”:"testmail@mydomain.com",“mailUseTls”:true}

I guess ‘username’ and ‘password’ should be your account name and password at google.com instead of mydomain.com.

535 error is for the SMTP authentication, normally, and nearly in all cases, are of an incorrect username/password toward the SMTP server

Well, the “mydomain.com” is just a placeholder since the email account is from gsuite, the gmail account is the correct one and so is the password, as I have tested it.

then maybe you need to go through the trouble-shooting procedures one by one, which is provided by google already to you. For example, try to turn on “Less secure app access” for your google account.

SMTP is a quite mature protocal, so normally the problem is in the settings instead of the software.

I have already done this: “Less secure app access”. As I have described in the original post.

I know it is a mature protocol. The problem here lies with the inconsistencies between the configuration files, and the UI. And whether or not there are more Environment variables that may be overriding these options.

I keep all my email settings in the .env file only. You might go through your config.yml and sentry.conf.py to eliminate any possible email setting confiction/override .

1 Like

Your username seems to be smtp.gmail.com (from your screenshot) which is 100% incorrect. I don’t know which request you are looking at but I’d recommend checking (or sharing) your config.yaml and sentry.conf.py files to make sure there are no overrides there. This also includes any environment variables that you may be consuming from there.

I thought that at first, however the response from the request that retrieves that information returns the correct username:

“mailUsername”:"sentry@mydomain.com"

The configuration, as I have shared above, seems to be correct, and sentry.conf.py does not have any line relating to email since I am using the default one, provided in version 10 on the onpremises github repository.
There is also no other Env. Var on the docker compose relating to SMTP configuration.

Can you share the output of docker-compose run --rm web config get mail.username?

Here it is, i just removed the domain:

Starting onpremise_redis_1        ... done
Starting onpremise_memcached_1    ... done
Starting onpremise_clickhouse_1   ... done
Starting onpremise_zookeeper_1    ... done
Starting onpremise_smtp_1         ... done
Starting onpremise_kafka_1        ... done
Starting onpremise_snuba-replacer_1 ... done
Starting onpremise_snuba-consumer_1 ... done
Starting onpremise_snuba-api_1      ... done
10:52:27 [WARNING] sentry.utils.geo: settings.GEOIP_PATH_MMDB not configured.
10:52:34 [INFO] sentry.plugins.github: apps-not-configured
        type: STRING
 from config: sentry@-----
     current: sentry@-----

Can you also verify the other mailing settings, just to be sure?

Checked all of them and they all have the same values from the config. Everything seems correct.

@luisg0nc - I’m out of ideas here. Have you tried these credentials with another mailing application? We sure know SMTP support works. I’m just trying to figure out what may be causing this. I’m also guessing you are using an “app password” for this, right? Also assuming you have tried this step from Google’s troubleshooting guide:

If the tips above didn’t help, visit https://www.google.com/accounts/DisplayUnlockCaptcha and follow the steps on the page.