My Contribution in K9 Android Mail Client
K-9 is an attractive, open-source email client for Android with support of IMAP, POP3, SMTP, and exchange protocols. Hence, this client does not support proxy feature. This problem is referenced in #704 #980 #2619. In this post I will talk about my contribution in K-9 project by adding SOCKs proxy feature, which can be used for connecting hidden mail services.
In previous post, I described about connecting Thunderbird, an open source email client for PC, to a hidden mail service. In this post I will talk about modifying K-9 mail and connecting Android client to the hidden mail service.
Problem Definition
Despite K-9 mail client is very powerful, it does not support SOCKs proxy feature. SOCKs proxy can be used for accessing the Internet in some special cases such as in schools, universities, or accessing TOR network.
By adding SOCKs proxy, one can connect to hidden mail services or to normal mail services by hiding his real IP address.
My Solution
I have worked with TOR hidden network and programming sockets in order to be connected through TOR network. You may check my answer in TOR stack exchange.
Therefore I just forked K-9 mail project into Mr Tajbakhsh github and worked on adding SOCKs proxy feature. I added a user interface part and modified the main connection source code.
Modifications
You can check the full list of modifications in github link. But there are two parts: one for the UI and one for the connection part.
UI Part
- app/core/src/main/java/com/fsck/k9/K9.java
- app/core/src/main/java/com/fsck/k9/preferences/GlobalSettings.java
- app/core/src/main/java/com/fsck/k9/preferences/Settings.java
- app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt
- app/ui/src/main/res/values/strings.xml
- app/ui/src/main/res/xml/general_settings.xml
Connection Part
- mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/ImapConnection.java
- mail/protocols/pop3/src/main/java/com/fsck/k9/mail/store/pop3/Pop3Connection.java
- mail/protocols/smtp/src/main/java/com/fsck/k9/mail/transport/smtp/SmtpTransport.java
- mail/protocols/webdav/src/main/java/com/fsck/k9/mail/store/webdav/WebDavStore.java
Connecting to Hidden Mail Server
I previously configured a hidden mail server using TOR and hMailServer. In another post, I described about connecting to the configured hidden mail server using Thunderbird.
Step 1: Generating The SOCKs Supported APK
The generation of APK is out of scope of this post, but generally you can fork the code from my Github repository and import it to Android Studio to get an APK.
Step 2: Installing TOR on Android
This step is straight forward. Just install TOR from Google Play and run it.
Step 3: Install and Configure K-9 With SOCKs Support
After compiling K-9 with SOCKs support, you can add email accounts based on Hidden mail server.
Every thing is done. Just start TOR in your Android phone and check SOCKs proxy in K-9 Network Configuration which added.
Conclusion
I added SOCKs proxy feature to K-9, the powerful and open source email client in Android. By using this feature, one can be connect to the email accounts if is behind SOCKs proxy or can be used in order to make a connect to hidden mail service. Enjoy!