The problem is that when I try to execute email sending from Google Cloud Run, it fails with jakarta.mail.AuthenticationFailedException: 535 Incorrect authentication data. The handshake with the SMPT server on port 465 passes, but it fails at the authentication step. Using the exact same code, configuration and credentials works from my local machine pretty well. What could be the reason for this?
Is your google environment configured with Private Access? Do you have google workspace email domain restrictions (DMARC/SPF/DKIM)? do you have an outbound Firewall policy/rule allowing Secure SMPT to the destination? Have you validated DNS ? Have you validated the Secure SMTP key ? A 535 typically means a failed handshake with the email server - this can be due to the key exchange, user authentication or domain restrictions.