Sending mail functionality for Google App Engine

Table of contents
Reading Time: < 1 minute

When we search for sending mail functionality then we get the solution using javax mail API.

Following is the code of using javax.mail API :

If you are using free app on Google App Engine then above code will not work and will get following error:

In above code, we are trying to set smtp configuration. When we use smtp configuration then Google App Engine tries to use Socket API and these Socket APIs are available only with paid apps. If you will use above code with free app on Google App Engine then we will get above error.

So, to avoid this error, use following code :

There is one more possibility that you can get following error as well:

This error comes when sender email address is not added in permission list in your app on Google App Engine. So sender email must be added in permission list.

If you want to get more on this then see here

Written by 

Rishi is a tech enthusiast with having around 10 years of experience who loves to solve complex problems with pure quality. He is a functional programmer and loves to learn new trending technologies. His leadership skill is well prooven and has delivered multiple distributed applications with high scalability and availability by keeping the Reactive principles in mind. He is well versed with Scala, Akka, Akka HTTP, Akka Streams, Java8, Reactive principles, Microservice architecture, Async programming, functional programming, distributed systems, AWS, docker.