From fb89889eae1ce63063c2c02e10c5d9dee79172ea Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Wed, 19 Oct 2022 12:17:58 -0300 Subject: [PATCH] Support Azure POP3 OAUTH Login in two lines --- .../java/com/genexus/internet/POP3SessionJavaMail.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gxmail/src/main/java/com/genexus/internet/POP3SessionJavaMail.java b/gxmail/src/main/java/com/genexus/internet/POP3SessionJavaMail.java index f7a9208a3..85acb9c91 100644 --- a/gxmail/src/main/java/com/genexus/internet/POP3SessionJavaMail.java +++ b/gxmail/src/main/java/com/genexus/internet/POP3SessionJavaMail.java @@ -77,8 +77,12 @@ public void login(GXPOP3Session sessionInfo) props.setProperty("mail.pop3.connectiontimeout", String.valueOf(timeout)); props.setProperty("mail.pop3.timeout", String.valueOf(timeout)); - if (sessionInfo.getAuthenticationMethod().length() > 0) { - props.setProperty("mail.pop3.auth.mechanisms", sessionInfo.getAuthenticationMethod().toUpperCase()); + String authMethod = sessionInfo.getAuthenticationMethod(); + if (!authMethod.isEmpty()) { + props.setProperty("mail.pop3.auth.mechanisms", authMethod.toUpperCase()); + if (authMethod.equalsIgnoreCase("XOAUTH2") && pop3Host.equalsIgnoreCase("outlook.office365.com")) { + props.setProperty("mail.pop3.auth.xoauth2.two.line.authentication.format", "true"); + } } props.setProperty("mail.pop3.ssl.enable", String.valueOf(secureConnection));