mguessan / davmail

DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange and Office 365 Gateway - Synced with main subversion repository at
http://davmail.sourceforge.net
GNU General Public License v2.0
557 stars 82 forks source link

[FR] Standalone android app #84

Open ildar opened 4 years ago

ildar commented 4 years ago

Possible to make an android app basing on DavMail code?

mguessan commented 4 years ago

Not impossible but tricky, you would have to find a DavMail version of each dependency. It would probably be easier to create a dedicated mail provider inspired by DavMail EWS implementation.

atelszewski commented 1 year ago

Hi,

I successfully run DavMail in Termux on an Android tablet. I needed to install openjdk-17 package to provide Java. I configured it and tested initially on a Linux PC.

BalooRJ1 commented 1 year ago

Hi,

I successfully run DavMail in Termux on an Android tablet. I needed to install openjdk-17 package to provide Java. I configured it and tested initially on a Linux PC.

Hi,

I successfully run DavMail in Termux on an Android tablet. I needed to install openjdk-17 package to provide Java. I configured it and tested initially on a Linux PC.

Thanks for this information! Does running Davmail in Termux on Android still require an SSL Key to use Davmail? An Android app would be much better than the current system of having to setup a server and point it out for everyone on the internet to access. Could you write up some instructions on how to install Davmail and use in Termux for us Android GrapheneOS/K-9/FairEmajl users? Thank you.

atelszewski commented 12 months ago

Hi Christian,

Does running Davmail in Termux on Android still require an SSL Key to use Davmail?

I don't know what it's meant for, but no, I didn't need to use SSL. I connect from FairEmail and DAVx5 to DavMail server running on localhost without encryption.

Could you write up some instructions on how to install Davmail and use in Termux for us Android GrapheneOS/K-9/FairEmajl users? Thank you.

Sure! :-)

You'll need to install the following Termux packages:

Some notes:

Below comes the DavMail configuration file I use. Please remember to provide your own davmail.oauth.*.refreshToken= token(s). Also, before using this config, make sure all the config options suit your needs.

davmail.ssl.keystoreType=
davmail.ssl.keystorePass=
davmail.proxyPassword=
davmail.oauth.tenantId=
davmail.oauth.clientId=d3590ed6-52b3-4102-aeff-aad2292ab01c
davmail.smtpPort=1025
davmail.enableKerberos=false
davmail.folderSizeLimit=0
davmail.forceActiveSyncUpdate=true
davmail.imapAutoExpunge=true
davmail.useSystemProxies=false
davmail.proxyUser=
davmail.caldavEditNotifications=false
davmail.ssl.nosecuresmtp=false
davmail.caldavPastDelay=
davmail.ssl.keyPass=
log4j.logger.httpclient.wire=INFO
davmail.noProxyFor=
davmail.server=true
davmail.popMarkReadOnRetr=false
davmail.ssl.nosecureimap=false
davmail.disableTrayActivitySwitch=false
davmail.caldavAutoSchedule=false
davmail.enableProxy=false
davmail.proxyPort=
davmail.logFileSize=1MB
davmail.mode=O365Modern
davmail.smtpSaveInSent=false
davmail.bindAddress=localhost
davmail.ssl.nosecurepop=false
davmail.ssl.pkcs11Library=
log4j.rootLogger=INFO
davmail.ssl.keystoreFile=
log4j.logger.davmail=INFO
davmail.clientSoTimeout=
davmail.ssl.clientKeystoreType=
davmail.ssl.pkcs11Config=
davmail.ssl.clientKeystorePass=
davmail.imapPort=1143
davmail.url=https://outlook.office365.com/EWS/Exchange.asmx
log4j.logger.org.apache.http.conn.ssl=INFO
davmail.sentKeepDelay=0
davmail.ssl.nosecureldap=false
davmail.imapAlwaysApproxMsgSize=false
davmail.ssl.nosecurecaldav=false
davmail.popPort=
davmail.defaultDomain=
davmail.showStartupBanner=false
log4j.logger.httpclient=INFO
davmail.proxyHost=
davmail.oauth.persistToken=true
davmail.ldapPort=1389
davmail.server.certificate.hash=
log4j.logger.org.apache.http.wire=INFO
davmail.disableGuiNotifications=true
davmail.imapIdleDelay=1
davmail.allowRemote=false
davmail.disableUpdateCheck=true
log4j.logger.org.apache.http=INFO
davmail.caldavPort=1080
davmail.enableKeepAlive=true
davmail.ssl.clientKeystoreFile=
davmail.logFilePath=/data/data/com.termux/files/home/.davmail.log
davmail.carddavReadPhoto=true
davmail.keepDelay=0
davmail.oauth.redirectUri=urn:ietf:wg:oauth:2.0:oob
davmail.caldavAlarmSound=

Provided that you unpacked the DavMail binaries archive in ~/davmail, i.e. ~/davmail/davmail.jar is present, start it with the script below.

#!/bin/bash

JAVA_OPTS=(
    -Xmx128M
    -Dsun.net.inetaddr.ttl=60
)

DAVMAIL_BASE_DIR=/data/data/com.termux/files/home/davmail
OPENJFX_BASE_DIR=/data/data/com.termux/files/home/davmail/javafx
OPENJFX_JARS_DIR=${OPENJFX_BASE_DIR}/lib

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}${OPENJFX_BASE_DIR}/lib

printf 'DAVMAIL_BASE_DIR=%s\n' "${DAVMAIL_BASE_DIR}"
printf 'OPENJFX_BASE_DIR=%s\n' "${OPENJFX_BASE_DIR}"
printf ' LD_LIBRARY_PATH=%s\n' "${LD_LIBRARY_PATH}"

  JFX_CLASSPATH=${OPENJFX_JARS_DIR}/javafx.base.jar
JFX_CLASSPATH+=:${OPENJFX_JARS_DIR}/javafx.controls.jar
JFX_CLASSPATH+=:${OPENJFX_JARS_DIR}/javafx.fxml.jar
JFX_CLASSPATH+=:${OPENJFX_JARS_DIR}/javafx.graphics.jar
JFX_CLASSPATH+=:${OPENJFX_JARS_DIR}/javafx.media.jar
JFX_CLASSPATH+=:${OPENJFX_JARS_DIR}/javafx.swing.jar
JFX_CLASSPATH+=:${OPENJFX_JARS_DIR}/javafx-swt.jar
JFX_CLASSPATH+=:${OPENJFX_JARS_DIR}/javafx.web.jar

cd -- "${DAVMAIL_BASE_DIR}"
exec -- screen -S davmail -d -m      \
    java "${JAVA_OPTS[@]}"           \
    -cp davmail.jar:${JFX_CLASSPATH} \
    davmail.DavGateway

That's all for now. Please let me know should you need further assistance.

-- Best regards, Andrzej Telszewski

BalooRJ1 commented 11 months ago

Thanks for posting this. Unfortunately I was unable to run the bash script through Termux on Android....I am probably not tech-savvy enough to accomplish this. I will hold out hope for a general Android app for Davmail to use with K-9 Mail in light of the fact that Davmail is the only free way to use Office365 accounts with Thunderbird and other FOSS Email programs.

atelszewski commented 11 months ago

Hi,

if you feel like, I might try to assist you.

-- Best regards, Andrzej Telszewski

BalooRJ1 commented 11 months ago

I would greatly appreciate that @atelszewski. Do you use Matrix? I can be reached at @baloorj:matrix.org

atelszewski commented 10 months ago

Hi,

please forgive me my late reply -- too many things, too little time. ;-) I don't have Matrix, but let's just stick here in the GitHub.

For now, let's forget about the Bash script.

Provided that:

go to where the package is extracted and run davmail with:

$ java -cp davmail.jar davmail.DavGateway

Let me know where you're at with the above steps and we'll continue from there. (Just please understand I might require time to respond -- but I surely will.)

epagone commented 6 months ago

Just to report that I have been successful installing Termux packages openjdk-17 and screen, unzipping DavMail archive in ~/davmail, copying my davmail.properties from my computer (where I have used O365Interactive to obtain authentication tokens) with minimal edits to activate the "server" mode, and running (from ~/davmail)

$ ./davmail davmail.properties

Then, I could configure K-9 Mail easily (following the instructions on the DavMail website for Thunderbird). I've currently done minimal testing (just receiving and sending emails) but it seems to work ok. I'm using Graphene OS.

I'd like to thank a lot @atelszewski for the information provided that has been very valuable, although I finally didn't use the script that he has kindly shared (it didn't work for me).

I still join the others in considering that a DavMail Andriod app would be very valuable (thanks a lot @mguessan for creating DavMail!).

atelszewski commented 6 months ago

Hi,

glad to hear that! :-)

Happy (Dav)Mailing! :-)

-- Best regards, Andrzej Telszewski

epagone commented 5 months ago

An update after a bit of experimentation (I hope it's not OT, please let me know otherwise).

Although the arrangement mentioned in my previous message works, it is not very practical as a daily driver.

I have three main problems (none of them appears to be clearly and directly related with DavMail, though).

  1. Termux cannot run in additional Android profiles (only in the main one) and, although it looks like the next release will address this, I'm not holding my breath until then (timing seems to be unclear). I'm looking for another app, but I'm quite new to the Android world. This is obviously unrelated to DavMail, but suggestions are very welcome.
  2. K9 Mail seems to be plagued by some subtle, but critical issues for my use case (examples here: one, two, three) that I will assume are not triggered or exacerbated by my DavMail configuration. :thinking:
  3. K9 Mail is slow to notify changes or send emails (far slower than a 10+ year old PC where I'm running DavMail too). Sometimes I send emails and somehow they sit in the Outbox for tens of minutes before being sent. I think emails should be parked in the Outbox only when there's a network connection error or poor connectivity. However, my connectivity is reasonably fast and definitely stable. Maybe also this is related to K9 Mail (although I've already disabled Polling and activated Push with no joy) but I feel doubtful that this problem might be also caused by my DavMail configuration.

This is my properties file

davmail.ssl.keystoreType=
davmail.ssl.keystorePass=
davmail.proxyPassword=
davmail.oauth.tenantId=
davmail.oauth.clientId=
davmail.smtpPort=1025
davmail.enableKerberos=false
davmail.folderSizeLimit=
davmail.forceActiveSyncUpdate=true
davmail.imapAutoExpunge=true
davmail.useSystemProxies=false
davmail.proxyUser=
davmail.caldavEditNotifications=false
davmail.ssl.nosecuresmtp=false
davmail.caldavPastDelay=
davmail.ssl.keyPass=
log4j.logger.httpclient.wire=INFO
davmail.noProxyFor=
davmail.server=true
davmail.popMarkReadOnRetr=false
davmail.ssl.nosecureimap=false
davmail.disableTrayActivitySwitch=false
davmail.caldavAutoSchedule=false
davmail.enableProxy=false
davmail.proxyPort=
davmail.logFileSize=1MB
davmail.mode=O365Modern
davmail.smtpSaveInSent=false
davmail.bindAddress=localhost
davmail.ssl.nosecurepop=false
davmail.ssl.pkcs11Library=
log4j.rootLogger=INFO
davmail.ssl.keystoreFile=
log4j.logger.davmail=INFO
davmail.clientSoTimeout=
davmail.ssl.clientKeystoreType=
davmail.ssl.pkcs11Config=
davmail.ssl.clientKeystorePass=
davmail.imapPort=1143
davmail.url=https://outlook.office365.com/EWS/Exchange.asmx
log4j.logger.org.apache.http.conn.ssl=INFO
davmail.sentKeepDelay=0
davmail.ssl.nosecureldap=false
davmail.imapAlwaysApproxMsgSize=false
davmail.ssl.nosecurecaldav=false
davmail.popPort=
davmail.defaultDomain=
davmail.showStartupBanner=false
log4j.logger.httpclient=INFO
davmail.proxyHost=
davmail.oauth.persistToken=true
davmail.ldapPort=1389
davmail.server.certificate.hash=
log4j.logger.org.apache.http.wire=INFO
davmail.disableGuiNotifications=true
davmail.imapIdleDelay=1
davmail.allowRemote=false
davmail.disableUpdateCheck=true
log4j.logger.org.apache.http=INFO
davmail.caldavPort=1080
davmail.enableKeepAlive=true
davmail.ssl.clientKeystoreFile=
davmail.oauth.REDACTED.refreshToken=REDACTED
davmail.logFilePath=/data/data/com.termux/files/home/.davmail.log
davmail.carddavReadPhoto=true
davmail.keepDelay=0
davmail.oauth.redirectUri=
davmail.caldavAlarmSound=

And this is an excerpt for a few minutes of usage from the log (Termux+K9 Mail):

Using system provided JRE
2024-01-10 18:48:54,819 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:46604 
2024-01-10 18:48:56,331 INFO  [ImapConnection-46604] davmail.connection  - LOGON - 127.0.0.1:46604 EMAIL REDACTED HERE
2024-01-10 18:48:56,381 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:46620 
2024-01-10 18:48:56,510 INFO  [ImapConnection-46620] davmail.connection  - LOGON - 127.0.0.1:46620 EMAIL REDACTED HERE
2024-01-10 18:49:58,176 INFO  [ImapConnection-46604] davmail.connection  - DISCONNECT - 127.0.0.1:46604 
2024-01-10 18:49:58,868 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:41084 
2024-01-10 18:49:59,076 INFO  [ImapConnection-41084] davmail.connection  - LOGON - 127.0.0.1:41084 EMAIL REDACTED HERE
2024-01-10 18:51:00,793 INFO  [ImapConnection-41084] davmail.connection  - DISCONNECT - 127.0.0.1:41084 
2024-01-10 18:51:01,648 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:58436 
2024-01-10 18:51:01,806 INFO  [ImapConnection-58436] davmail.connection  - LOGON - 127.0.0.1:58436 EMAIL REDACTED HERE
2024-01-10 18:52:03,896 INFO  [ImapConnection-58436] davmail.connection  - DISCONNECT - 127.0.0.1:58436 
2024-01-10 18:52:05,079 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:56442 
2024-01-10 18:52:05,295 INFO  [ImapConnection-56442] davmail.connection  - LOGON - 127.0.0.1:56442 EMAIL REDACTED HERE
2024-01-10 18:53:07,021 INFO  [ImapConnection-56442] davmail.connection  - DISCONNECT - 127.0.0.1:56442 
2024-01-10 18:53:08,070 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:60416 
2024-01-10 18:53:08,231 INFO  [ImapConnection-60416] davmail.connection  - LOGON - 127.0.0.1:60416 EMAIL REDACTED HERE
2024-01-10 18:54:09,827 INFO  [ImapConnection-60416] davmail.connection  - DISCONNECT - 127.0.0.1:60416 
2024-01-10 18:54:10,867 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:60152 
2024-01-10 18:54:11,068 INFO  [ImapConnection-60152] davmail.connection  - LOGON - 127.0.0.1:60152 EMAIL REDACTED HERE
2024-01-10 18:55:12,499 INFO  [ImapConnection-60152] davmail.connection  - DISCONNECT - 127.0.0.1:60152 
2024-01-10 18:55:13,377 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:45758 
2024-01-10 18:55:13,556 INFO  [ImapConnection-45758] davmail.connection  - LOGON - 127.0.0.1:45758 EMAIL REDACTED HERE
2024-01-10 18:56:15,106 INFO  [ImapConnection-45758] davmail.connection  - DISCONNECT - 127.0.0.1:45758 
2024-01-10 18:56:17,728 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:58262 
2024-01-10 18:56:17,898 INFO  [ImapConnection-58262] davmail.connection  - LOGON - 127.0.0.1:58262 EMAIL REDACTED HERE
2024-01-10 18:57:19,431 INFO  [ImapConnection-58262] davmail.connection  - DISCONNECT - 127.0.0.1:58262 
2024-01-10 18:57:35,658 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:52720 
2024-01-10 18:57:35,815 INFO  [ImapConnection-52720] davmail.connection  - LOGON - 127.0.0.1:52720 EMAIL REDACTED HERE
2024-01-10 18:58:37,230 INFO  [ImapConnection-52720] davmail.connection  - DISCONNECT - 127.0.0.1:52720 
2024-01-10 18:58:38,900 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:60040 
2024-01-10 18:58:39,031 INFO  [ImapConnection-60040] davmail.connection  - LOGON - 127.0.0.1:60040 EMAIL REDACTED HERE
2024-01-10 18:59:40,269 INFO  [ImapConnection-60040] davmail.connection  - DISCONNECT - 127.0.0.1:60040 
2024-01-10 18:59:43,140 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:47878 
2024-01-10 18:59:43,323 INFO  [ImapConnection-47878] davmail.connection  - LOGON - 127.0.0.1:47878 EMAIL REDACTED HERE
2024-01-10 19:00:44,868 INFO  [ImapConnection-47878] davmail.connection  - DISCONNECT - 127.0.0.1:47878 
2024-01-10 19:00:47,814 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:50552 
2024-01-10 19:00:48,015 INFO  [ImapConnection-50552] davmail.connection  - LOGON - 127.0.0.1:50552 EMAIL REDACTED HERE
2024-01-10 19:01:49,519 INFO  [ImapConnection-50552] davmail.connection  - DISCONNECT - 127.0.0.1:50552 
2024-01-10 19:01:51,152 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 127.0.0.1:54438 
2024-01-10 19:01:51,330 INFO  [ImapConnection-54438] davmail.connection  - LOGON - 127.0.0.1:54438 EMAIL REDACTED HERE
2024-01-10 19:02:38,790 INFO  [davmail.imap.ImapServer] davmail.connection  - DISCONNECT - 127.0.0.1:54438 
2024-01-10 19:02:38,791 WARN  [ImapConnection-54438] davmail.imap.ImapConnection  - Client closed connection
2024-01-10 19:02:38,791 INFO  [ImapConnection-54438] davmail.connection  - DISCONNECT - 127.0.0.1:54438 
2024-01-10 19:02:38,793 INFO  [Shutdown] davmail  - DavMail gateway stopped

Is such a continuous sequence of disconnect-connect-logon in a short time normal? I don't seem to have this in my PC logs. Do you see anything to be fixed with the above?

I'm trying FairEmail as email client but I have not yet found an app that can substitute Termux and work in a secondary profile (any suggestions?)

I'm posting just to share my experience and (hopefully) get some suggestions.

atelszewski commented 5 months ago

Hi,

when it comes to using multiple profiles, unfortunately I have no experience.

when it comes to sending/ receiving e-mails and syncing calendars, I use FairEmail and DAVx5.

I have most of the time no issues, both e-mail and calendar sync works well. I have 2 Microsoft accounts, and funnily, one is faster to sync than the other.

On a side note, I have FairEmail configured to fetch messages only manually. This is because my personal preference to be able to decide when the messages are downloaded. But maybe it also makes the setup more stable? The IMAP connection is only established when needed.

One more note: I experience issues with some messages, as described in #313. That's still something I need to solve.

-- Best regards, Andrzej Telszewski

epagone commented 5 months ago

Thanks for the suggestions @atelszewski

Another update. I have tried FairEmail with Termux and it is much more functional, stable and prompt: although I've tested it for a short time, for now it is working really well! If this continues to be the case, problems 2 and 3 in my previous message (together with a few, less severe ones) are solved :+1: Definitely a strong suggestion for everyone interested in this issue.

Concerning the last problem (i.e. finding a substitute of Termux to launch the local DavMail server from an additional profile), I did find NeoTTY and (after quite a bit of experimentation) I was able to install permanent Alpine Linux with it (default is a diskless distribution), and install Java (package openjdk11) in it. However, when I

The script starts but hangs. The log file is empty (there is only a line recording when DavMail has been stopped). However, if I start DavMail without specifying a configuration file (i.e. # davmail), it runs and records some activities in the log.

This is a diff of "my" properties file that hangs < vs the default file that runs >

4,5d3
< davmail.oauth.tenantId=
< davmail.oauth.clientId=
9c7
< davmail.forceActiveSyncUpdate=true
---
> davmail.forceActiveSyncUpdate=false
13d10
< davmail.caldavEditNotifications=false
15c12
< davmail.caldavPastDelay=
---
> davmail.caldavPastDelay=0
17c14
< log4j.logger.httpclient.wire=INFO
---
> log4j.logger.httpclient.wire=WARN
19c16
< davmail.server=true
---
> davmail.server=false
23c20
< davmail.caldavAutoSchedule=false
---
> davmail.caldavAutoSchedule=true
26,29c23,25
< davmail.logFileSize=1MB
< davmail.mode=O365Modern
< davmail.smtpSaveInSent=false
< davmail.bindAddress=localhost
---
> davmail.mode=EWS
> davmail.smtpSaveInSent=true
> davmail.bindAddress=
32c28
< log4j.rootLogger=INFO
---
> log4j.rootLogger=WARN
34,35c30
< log4j.logger.davmail=INFO
< davmail.clientSoTimeout=
---
> log4j.logger.davmail=DEBUG
36a32
> davmail.clientSoTimeout=
38d33
< davmail.ssl.clientKeystorePass=
39a35
> davmail.ssl.clientKeystorePass=
41d36
< log4j.logger.org.apache.http.conn.ssl=INFO
46,49c41,43
< davmail.popPort=
< davmail.defaultDomain=
< davmail.showStartupBanner=false
< log4j.logger.httpclient=INFO
---
> davmail.popPort=1110
> davmail.showStartupBanner=true
> log4j.logger.httpclient=WARN
51d44
< davmail.oauth.persistToken=true
54,56c47,48
< log4j.logger.org.apache.http.wire=INFO
< davmail.disableGuiNotifications=true
< davmail.imapIdleDelay=1
---
> davmail.disableGuiNotifications=false
> davmail.imapIdleDelay=
58,59c50
< davmail.disableUpdateCheck=true
< log4j.logger.org.apache.http=INFO
---
> davmail.disableUpdateCheck=false
61c52
< davmail.enableKeepAlive=true
---
> davmail.enableKeepAlive=false
63,64c54
< davmail.oauth.EMAIL REDACTED.refreshToken=TOKEN REDACTED
< davmail.logFilePath=/root/davmail/davmail.log
---
> davmail.logFilePath=
66,67c56
< davmail.keepDelay=0
< davmail.oauth.redirectUri=
---
> davmail.keepDelay=30

Do you see anything wrong? Could you suggest anything? I feel I'm quite close to the finishing line, but I might be wrong.