RStudio Connect mail sending problem with Gmail SMTP

We've been using Gmail SMTP for RStudio Connect emails for a few months without a problem and then just recently we started to get the error "Username and password not accepted" from Gmail. I was able to get it to work again by changing the 'Allow less secure apps' setting to 'yes' in our Gmail account.

Is there a more secure way to connect?

Hello @young and welcome to the RStudio community!

That is an interesting case! I have to admit that I am not familiar with using Gmail as an SMTP server. It is definitely unfortunate to have Connect classified as a "less secure app" :stuck_out_tongue:

I suspect part of this is because Gmail is a unique beast. Are you using an "App Password"? It is not super clear what the solution to this problem is, but I suspect part of is that "more secure apps" have an OAuth or other API relationship with Gmail directly.

Our implementation is generic SMTP, so it may be that Google wants us to be more of an explicit "Gmail" provider.

This thread on StackOverflow suggests that maybe you just need to enable SMTP.SSL in the RStudio Connect configuration, though?

Did you arrive at any more secure solution to SMTP with Gmail? We are having the same issue with a client, and since the “Allow Less Secure Apps” option in Gmail is going away in a few weeks, we would like to set up the connection securely. Tried using an app password but still no luck… I imagine there must be folks out there who are using the Gmail SMTP client with RStudio Connect.