diff --git a/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java b/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java index 3b221b45f..b90b1c0ab 100644 --- a/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java +++ b/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java @@ -56,6 +56,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, private ViewGroup mRequireLoginSettingsView; private Spinner mSecurityTypeView; private Spinner mAuthTypeView; + private ArrayAdapter mAuthTypeAdapter; private Button mNextButton; private Account mAccount; private boolean mMakeDefault; @@ -125,10 +126,11 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSecurityTypeView.setAdapter(securityTypesAdapter); - ArrayAdapter authTypesAdapter = new ArrayAdapter(this, - android.R.layout.simple_spinner_item, AuthType.values()); - authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mAuthTypeView.setAdapter(authTypesAdapter); + AuthType[] acceptableAuthTypes = {AuthType.AUTOMATIC, AuthType.PLAIN, AuthType.CRAM_MD5}; + mAuthTypeAdapter = new ArrayAdapter(this, + android.R.layout.simple_spinner_item, acceptableAuthTypes); + mAuthTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mAuthTypeView.setAdapter(mAuthTypeAdapter); /* * Calls validateFields() which enables or disables the Next button @@ -196,7 +198,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, } if (authType != null) { - int position = AuthType.valueOf(authType).ordinal(); + int position = mAuthTypeAdapter.getPosition(AuthType.valueOf(authType)); mAuthTypeView.setSelection(position, false); } diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index 3e029d954..e0a48441f 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -305,12 +305,11 @@ public class SmtpTransport extends Transport { } } - boolean useAuthLogin = AuthType.LOGIN.equals(mAuthType); - boolean useAuthPlain = AuthType.PLAIN.equals(mAuthType); + boolean useAuthPlain = AuthType.PLAIN.equals(mAuthType) || AuthType.LOGIN.equals(mAuthType); boolean useAuthCramMD5 = AuthType.CRAM_MD5.equals(mAuthType); // Automatically choose best authentication method if none was explicitly selected - boolean useAutomaticAuth = !(useAuthLogin || useAuthPlain || useAuthCramMD5); + boolean useAutomaticAuth = !(useAuthPlain || useAuthCramMD5); boolean authLoginSupported = false; boolean authPlainSupported = false; @@ -360,11 +359,7 @@ public class SmtpTransport extends Transport { throw ex; } } - } else if (useAuthLogin || (useAutomaticAuth && authLoginSupported)) { - if (!authPlainSupported && K9.DEBUG && K9.DEBUG_PROTOCOL_SMTP) { - Log.d(K9.LOG_TAG, "Using LOGIN as authentication method although the " + - "server didn't advertise support for it in EHLO response."); - } + } else if (useAutomaticAuth && authLoginSupported) { saslAuthLogin(mUsername, mPassword); } else { throw new MessagingException("No valid authentication mechanism found.");