I deployed a Spring Boot application on GKE, this app should send emails but it GKE blocks emails sending. On local machine I don't have any issue. My configurations:
spring.mail.default-encoding=UTF-8
spring.mail.protocol=smtps
spring.mail.port=465
spring.mail.host=smtp.<domain.com>
spring.mail.username=username
spring.mail.password=*****
spring.mail.properties.mail.smtps.auth=true
spring.mail.properties.mail.smtps.starttls.enable=true
spring.mail.properties.mail.debug=false
spring.mail.properties.mail.smtps.allow8bitmime=true
spring.mail.properties.mail.smtps.ssl.trust=smtp.<domain.com>
spring.mail.properties.mail.smtps.connectiontimeout=10000
spring.mail.properties.mail.smtps.timeout=6000
spring.mail.properties.mail.smtps.writetimeout=1000
Thanks for you help
By default, Google Cloud Platform allows outbound connections on all ports but port 25, which is blocked because of the risk of abuse. All other ports are open, including ports 587 and 465.
Please make sure your firewall rules are well defined.
If you are using a private GKE cluster and if your SMTP server is outside the VPC (used by the private GKE cluster), try using a Cloud NAT for the region (used by GKE cluster). This will allow outgoing traffic to SMTP server through the Cloud NAT.