https://stackoverflow.com/questions/21087564/gmail-smtp-is-not-working-in-ec2-instance

https://linuxconfig.org/configuring-gmail-as-sendmail-email-relay

Go to https://www.google.com/settings/security/lesssecureapps and set Access for less secure apps to On

goto : https://accounts.google.com/DisplayUnlockCaptcha

and click continue this going to allow access from other servers.

https://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/