Check SMTP server for alt username

This commit is contained in:
M66B 2021-06-17 18:11:06 +02:00
parent 38a497280b
commit 137e62406b
1 changed files with 27 additions and 13 deletions

View File

@ -471,6 +471,8 @@ public class FragmentOAuth extends FragmentBase {
EmailProvider provider = EmailProvider.getProvider(context, id); EmailProvider provider = EmailProvider.getProvider(context, id);
String aprotocol = (provider.imap.starttls ? "imap" : "imaps"); String aprotocol = (provider.imap.starttls ? "imap" : "imaps");
int aencryption = (provider.imap.starttls ? EmailService.ENCRYPTION_STARTTLS : EmailService.ENCRYPTION_SSL); int aencryption = (provider.imap.starttls ? EmailService.ENCRYPTION_STARTTLS : EmailService.ENCRYPTION_SSL);
String iprotocol = (provider.smtp.starttls ? "smtp" : "smtps");
int iencryption = (provider.smtp.starttls ? EmailService.ENCRYPTION_STARTTLS : EmailService.ENCRYPTION_SSL);
String username = address; String username = address;
@ -537,16 +539,30 @@ public class FragmentOAuth extends FragmentBase {
if (usernames.size() > 1) if (usernames.size() > 1)
for (String alt : usernames) { for (String alt : usernames) {
EntityLog.log(context, "Trying username=" + alt); EntityLog.log(context, "Trying username=" + alt);
try (EmailService iservice = new EmailService( try {
context, aprotocol, null, aencryption, false, try (EmailService aservice = new EmailService(
EmailService.PURPOSE_CHECK, true)) { context, aprotocol, null, aencryption, false,
iservice.connect( EmailService.PURPOSE_CHECK, true)) {
provider.imap.host, provider.imap.port, aservice.connect(
AUTH_TYPE_OAUTH, provider.id, provider.imap.host, provider.imap.port,
alt, state, AUTH_TYPE_OAUTH, provider.id,
null, null); alt, state,
null, null);
}
try (EmailService iservice = new EmailService(
context, iprotocol, null, iencryption, false,
EmailService.PURPOSE_CHECK, true)) {
iservice.connect(
provider.smtp.host, provider.smtp.port,
AUTH_TYPE_OAUTH, provider.id,
alt, state,
null, null);
}
EntityLog.log(context, "Using username=" + alt); EntityLog.log(context, "Using username=" + alt);
username = alt; username = alt;
break;
} catch (Throwable ex) {
Log.w(ex);
} }
} }
@ -595,22 +611,20 @@ public class FragmentOAuth extends FragmentBase {
List<EntityFolder> folders; List<EntityFolder> folders;
Log.i("OAuth checking IMAP provider=" + provider.id); Log.i("OAuth checking IMAP provider=" + provider.id);
try (EmailService iservice = new EmailService( try (EmailService aservice = new EmailService(
context, aprotocol, null, aencryption, false, context, aprotocol, null, aencryption, false,
EmailService.PURPOSE_CHECK, true)) { EmailService.PURPOSE_CHECK, true)) {
iservice.connect( aservice.connect(
provider.imap.host, provider.imap.port, provider.imap.host, provider.imap.port,
AUTH_TYPE_OAUTH, provider.id, AUTH_TYPE_OAUTH, provider.id,
username, state, username, state,
null, null); null, null);
folders = iservice.getFolders(); folders = aservice.getFolders();
} }
Log.i("OAuth checking SMTP provider=" + provider.id); Log.i("OAuth checking SMTP provider=" + provider.id);
Long max_size; Long max_size;
String iprotocol = (provider.smtp.starttls ? "smtp" : "smtps");
int iencryption = (provider.smtp.starttls ? EmailService.ENCRYPTION_STARTTLS : EmailService.ENCRYPTION_SSL);
try (EmailService iservice = new EmailService( try (EmailService iservice = new EmailService(
context, iprotocol, null, iencryption, false, context, iprotocol, null, iencryption, false,