Yes, at present there are so many disposable email service providers available in the market. they provide free public and private inbox for a temporary email address. Recently I found few very good disposable email service providers and one of them is ‘mail7.io’
Documentation is also very good.
To automate this, you can write the code something like the below mentioned:
public class ExampleUsageTest {
private static final String YOUR_API_KEY = "your_mail7_api_key_here";
private static final String YOUR_API_SECRET = "your_mail7_api_secret_here";
String getEmailBody(String UserName) throws IOException {
URL url = new URL(<a href="/%26quot%3Bhttps%3A//api.mail7.io/inbox?apikey">"https://api.mail7.io/inbox?apikey=</a>" + YOUR_API_KEY + "&apisecret=" + YOUR_API_SECRET + "&to=" + UserName);
HttpURLConnection con;
con = (HttpURLConnection) url.openConnection();
// handle error response code it occurs
int responseCode = con.getResponseCode();
InputStream inputStream;
if (200 <= responseCode && responseCode <= 299) {
inputStream = con.getInputStream();
} else {
inputStream = con.getErrorStream();
}
BufferedReader in =new BufferedReader(
new InputStreamReader(
inputStream));
StringBuilder response = new StringBuilder();
String currentLine;
while ((currentLine = in.readLine()) != null)
response.append(currentLine);
in .close();
return response.toString();
}
}
Please refer to this doc to get a better idea and solution for your problem. doc link