In many situations, it is convenient to retrieve, verify, and delete emails sent from an application. There are several JavaMail APIs that allow users to perform these actions. This section will cover using these APIs to get Google Mail Messages, get their content, get a URL link, and delete all messages once found:
The JavaDoc for the JavaMail class is located at https://docs.oracle.com/javaee/7/api/javax/mail/package-summary.html.
/**
* getGmailMessage - method to get the gmail message by username, password,
* and email account
*
* @param username
* @param password
* @param subject
* @param email
* @return Message
* @throws Exception
*/
public static Message getGmailMessage(String username,
String password,
String subject,
String email)
...