Repository: thundernest/k-9
Issue: Crash when editing outgoing server settings

**Describe the bug**
Ever since the [5.728](https://github.com/k9mail/k-9/releases/tag/5.728) update (with the long awaited [Add support for client certificate and password authentication](https://github.com/k9mail/k-9/issues/793#event-4298863970)) change, K-9 crashes when trying to send email over a (TLS-enabled) SMTP server.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to Settings => Account settings => Sending mail => Outgoing server
2. Optional: disable "require sign-in"
3. Tap on "Next"
4. K-9 crashes and goes back to the "Sending mail" screen.
5. Click "Next" again and K9 crashes and the Android  "K-9 Mail keeps stopping" screen comes up.

**Expected behavior**
K-9 should not crash :-)

**Environment (please complete the following information):**
 - K-9 Mail version: [5.731](https://github.com/k9mail/k-9/releases/tag/5.731) (Beta)
 - Android version: 11 (February 2021)
 - Device: Google Pixel 4a
 - Account type: IMAP + SMTP

**Logs**
When the "Next" button is pressed (and K-9 crashes), the following is being captured by `logcat`:

```
--------- beginning of crash
03-02 09:28:43.426 10303 10303 E AndroidRuntime: FATAL EXCEPTION: main
03-02 09:28:43.426 10303 10303 E AndroidRuntime: Process: com.fsck.k9, PID: 10303
03-02 09:28:43.426 10303 10303 E AndroidRuntime: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, paramet
er authenticationType
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at com.fsck.k9.mail.ServerSettings.<init>(Unknown Source:12)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at com.fsck.k9.mail.ServerSettings.<init>(ServerSettings.kt:17)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at com.fsck.k9.mail.ServerSettings.<init>(Unknown Source:18)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at com.fsck.k9.activity.setup.AccountSetupOutgoing.onNext(AccountSetupOutgoing.java:494)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at com.fsck.k9.activity.setup.AccountSetupOutgoing.onClick(AccountSetupOutgoing.java:503)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at android.view.View.performClick(View.java:7448)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at android.view.View.performClickInternal(View.java:7425)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at android.view.View.access$3600(View.java:810)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at android.view.View$PerformClick.run(View.java:28305)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:938)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:223)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7660)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
03-02 09:28:43.426 10303 10303 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
```

The crash looked a bit like the one reported in #5134, but the behaviour is different. K-9 works fine, _fetching_ and _reading_ mail works fine, only _sending_ crashes the application.

And, after the crash:

```
$ adb logcat -d --pid=$(adb shell pgrep k9)
--------- beginning of main
03-03 22:01:45.842 25439 25439 I libc    : SetHeapTaggingLevel: tag level set to 0
03-03 22:01:45.847 25439 25439 E com.fsck.k9: Not starting debugger since process cannot load the jdwp agent.
03-03 22:01:45.879 25439 25439 D ApplicationLoaders: Returning zygote-cached class loader: /system/framework/android.test.base.jar
03-03 22:01:45.893 25439 25439 D NetworkSecurityConfig: No Network Security Config specified, using platform default
03-03 22:01:45.893 25439 25439 D NetworkSecurityConfig: No Network Security Config specified, using platform default
03-03 22:01:45.922 25439 25439 I TetheringManager: registerTetheringEventCallback:com.fsck.k9
03-03 22:01:46.006 25439 25463 I AdrenoGLES-0: QUALCOMM build                   : 0905e9f, Ia11ce2d146
03-03 22:01:46.006 25439 25463 I AdrenoGLES-0: Build Date                       : 09/02/20
03-03 22:01:46.006 25439 25463 I AdrenoGLES-0: OpenGL ES Shader Compiler Version: EV031.31.04.00
03-03 22:01:46.006 25439 25463 I AdrenoGLES-0: Local Branch                     : gfx-adreno.lnx.2.0
03-03 22:01:46.006 25439 25463 I AdrenoGLES-0: Remote Branch                    : 
03-03 22:01:46.006 25439 25463 I AdrenoGLES-0: Remote Branch                    : 
03-03 22:01:46.006 25439 25463 I AdrenoGLES-0: Reconstruct Branch               : 
03-03 22:01:46.006 25439 25463 I AdrenoGLES-0: Build Config                     : S P 10.0.4 AArch64
03-03 22:01:46.006 25439 25463 I AdrenoGLES-0: Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
03-03 22:01:46.010 25439 25439 W ListPreference: Setting a summary with a String formatting marker is no longer supported. You should use a SummaryProvider instead.
03-03 22:01:46.010 25439 25463 I AdrenoGLES-0: PFP: 0x016ee189, ME: 0x00000000
03-03 22:01:46.011 25439 25463 W AdrenoUtils: <ReadGpuID_from_sysfs:197>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
03-03 22:01:46.012 25439 25463 W AdrenoUtils: <ReadGpuID:221>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
03-03 22:01:46.023 25439 25439 W ListPreference: Setting a summary with a String formatting marker is no longer supported. You should use a SummaryProvider instead.
03-03 22:01:46.042 25439 25463 I Gralloc4: mapper 4.x is not supported
```

Changed files:
app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupOutgoing.java

diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupOutgoing.java b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupOutgoing.java
index 443c4f9f8..e1c021243 100644
--- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupOutgoing.java
+++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupOutgoing.java
@@ -18,7 +18,6 @@ import android.widget.CheckBox;
 import android.widget.CompoundButton;
 import android.widget.CompoundButton.OnCheckedChangeListener;
 import android.widget.Spinner;
-import android.widget.TextView;
 import android.widget.Toast;
 
 import com.fsck.k9.Account;
@@ -472,10 +471,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
 
     protected void onNext() {
         ConnectionSecurity securityType = getSelectedSecurity();
-        String username = null;
+        String username = "";
         String password = null;
         String clientCertificateAlias = null;
-        AuthType authType = null;
+        AuthType authType = AuthType.AUTOMATIC;
         if ((ConnectionSecurity.STARTTLS_REQUIRED == securityType) ||
                 (ConnectionSecurity.SSL_TLS_REQUIRED == securityType)) {
             clientCertificateAlias = mClientCertificateSpinner.getAlias();