Check SMTP server for alt username

pull/199/head
M66B 3 years ago
parent 38a497280b
commit 137e62406b

@ -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 {
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,
alt, state, alt, state,
null, null); 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,

Loading…
Cancel
Save