How to send reportURL in an e-mail automatically?

In my code I use @AfterMethod to see the reportURL of the execution of the test.
I’m trying to use GMAIL SMTP to send it by e-mail everytime a test finishes. Do you guys know if it’s possible do it like:
> @AfterMethod

public void tearDown(ITestResult tr){
driver.removeApp(“com.consul.android.smartbeer.staging”);
if (driver!=null)
{
if (tr.isSuccess())
{
client.report(“Test has passed”, true);
}
else {
client.report(“Test has failed”, false);
}
System.out.println(“report URL : " + driver.getCapabilities().getCapability(“reportUrl”));
driver.quit();
// mailTo(lucas_m_santos@whirlpool.com).body(”"+reportURL)
}

}

Hi @LucasSantos ,

I personally haven’t tried it but a quick google showed me that you could use various libraries to accomplish this.
Here is one example: https://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/smtp/SMTPClient.html