Discussion:
[Davmail-users] Check connection
Geert Stappers
2017-01-07 17:24:59 UTC
Permalink
Hello,

Thing I miss in the documentation, is how to check the connection
that Davmail makes.

At http://davmail.sourceforge.net/ there is "Davmail setup"
and "Thunderbird setup" plus other client setups.

IMHO should be something in between. Here is my proposal:

--- src/site/site.xml (revision 2439)
+++ src/site/site.xml (working copy)
@@ -47,6 +47,10 @@
<item name="Kerberos" href="/kerberos.html"/>
</menu>

+ <menu name="Connection Check">
+ <item name="Check POP" href="/checkpop.html"/>
+ </menu>
+
<menu name="Thunderbird Setup">
<item name="POP Mail setup" href="/thunderbirdmailsetup.html"/>
<item name="IMAP Mail setup" href="/thunderbirdimapmailsetup.html"/>


In the attachments the XML file to generate checkpop.html

Also a Python script to check the POP connection.
Plus a README for a new directory site/resources/plaintext


Could this be added to Davmail SVN repository?


Groeten
Geert Stappers
Who will also send the output of `svn diff`.
Here is allready the output of `svn status`
|$ svn status src/site/
|A src/site/resources/plaintext
|A src/site/resources/plaintext/README.text
|A src/site/resources/plaintext/checkpop.py.text
|M src/site/site.xml
|A src/site/xdoc/checkpop.xml
The same output reordered and edited
|Modified src/site/site.xml
|Added file src/site/xdoc/checkpop.xml
|Added directory src/site/resources/plaintext
|Added file src/site/resources/plaintext/checkpop.py.text
|Added file src/site/resources/plaintext/README.text
--
Leven en laten leven
Geert Stappers
2017-01-07 17:42:53 UTC
Permalink
Post by Geert Stappers
Hello,
Thing I miss in the documentation, is how to check the connection
that Davmail makes.
At http://davmail.sourceforge.net/ there is "Davmail setup"
and "Thunderbird setup" plus other client setups.
<snip/>
Post by Geert Stappers
Groeten
Geert Stappers
Who will also send the output of `svn diff`.
Index: src/site/site.xml
===================================================================
--- src/site/site.xml (revision 2439)
+++ src/site/site.xml (working copy)
@@ -47,6 +47,10 @@
<item name="Kerberos" href="/kerberos.html"/>
</menu>

+ <menu name="Connection Check">
+ <item name="Check POP" href="/checkpop.html"/>
+ </menu>
+
<menu name="Thunderbird Setup">
<item name="POP Mail setup" href="/thunderbirdmailsetup.html"/>
<item name="IMAP Mail setup" href="/thunderbirdimapmailsetup.html"/>
Index: src/site/xdoc/checkpop.xml
===================================================================
--- src/site/xdoc/checkpop.xml (nonexistent)
+++ src/site/xdoc/checkpop.xml (working copy)
@@ -0,0 +1,164 @@
+<?xml version="1.0"?>
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+ <properties>
+ <title>DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway - Check POP</title>
+ <author email="***@stappers.nl">Geert Stappers</author>
+ </properties>
+ <body>
+ <section name="DavMail Check POP">
+ <subsection name="Telnet client is the tool">
+ <p>
+ This page describes checking DavMail POP connection.
+ It is a very basic test.
+ </p>
+ <p>
+ Tool that you need is a <i>good telnet client</i>.
+ Known good are the Linux telnet clients.
+ MacOS and other BSD devirates also.
+ The default Microsoft telnet client is a poor own,
+ consider using <i>putty</i>.
+ Putty is a SSH client which also can be a telnet client.
+ </p>
+ <p>
+ Davmail is running / started on <i>localhost</i>
+ and is configured for POP on port <i>1110</i>
+ </p>
+ <p>
+ Example user <i>mrose</i>
+ and password <i>secret</i>.
+ </p>
+ </subsection>
+ <subsection name="Happy flow">
+ <p>
+ <pre>
+$ telnet localhost 1110
+Trying ::1...
+Connected to localhost.
+Escape character is '^]'.
++OK DavMail 4.7.3-trunk POP ready at Mon Dec 26 12:56:27 CET 2016
+USER mrose
++OK USER : mrose
+PASS secret
++OK PASS
+STAT
++OK 3 320
+QUIT
++OK Bye
+Connection closed by foreign host.
+$
+ </pre>
+ All fine. You have 3 messages with total size of 320 octets.
+ </p>
+ <p>
+ What was typed in:
+<pre>
+telnet localhost 1110
+USER mrose
+PASS secret
+STAT
+QUIT
+</pre>
+ </p>
+ </subsection>
+ <subsection name="Experience">
+ <p>
+ The not so happy flow.
+ </p><p>
+<pre>
+$ telnet localhost 1110
+Trying ::1...
+Trying 127.0.0.1...
+telnet: Unable to connect to remote host: Connection refused
+$
+</pre>Davmail is not running or you are at the wrong place.
+Check why Davmail is not running.
+Check hostname and port number.
+ </p>
+ <hr/>
+ <p>
+ <pre>
+$ telnet localhost 1110
+Trying ::1...
+Connected to localhost.
+Escape character is '^]'.
+-ERR Invalid URL: foobar
+Connection closed by foreign host.
+$
+ </pre>
+ Check in davmail.properites the value of url
+ </p>
+ <hr/>
+ <p>
+<pre>
+$ telnet localhost 1110
+Trying ::1...
+Connected to localhost.
+Escape character is '^]'.
+-ERR DavMail configuration exception: Connect exception: java.net.UnknownHostException exchangeServer
+Connection closed by foreign host.
+$
+ </pre>In <code>davmail.properites</code> has the value of <code>url</code>
+ a hostname that can't be resolved.
+ Either DNS is broken or you misspelled the hostname.
+ </p>
+ <hr/>
+ <p>
+ <pre>
+$ telnet localhost 1110
+Trying ::1...
+Connected to localhost.
+Escape character is '^]'.
+-ERR All network interfaces down or host unreachable !
+Connection closed by foreign host.
+$
+ </pre>Check network connection, including compoments as a proxy.
+ </p>
+ </subsection>
+ <subsection name="Scripted check">
+ <p>
+There is a script <a href="plaintext/checkpop.py.txt">checkpop.py</a>.
+After download you can invoke it like<br/>
+<code>python checkpop.py mrose secret</code><br/>
+to check POP by script.
+</p>
+</subsection>
+ <subsection name="See also">
+ <p>
+ Other checks to see also.
+ </p>
+ <p> <a href="https://www.ietf.org/rfc/rfc1939.txt">
+ RFC - Post Office Protocol - Version 3
+ </a> </p>
+ <p>
+ <a href="checkimap.html">Check IMAP</a>
+ </p>
+ <p>
+ <a href="checksmtp.html">Check SMTP</a>
+ </p>
+ <p>
+ <a href="checkcaldav.html">Check Caldav</a>
+ </p>
+ <p>
+ <a href="checkcarddav.html">Check Carddav</a>
+ </p>
+ <p>
+ <a href="checkldap.html">Check LDAP</a>
+ </p>
+ <ul>
+ <li> <a href="https://www.ietf.org/rfc/rfc1939.txt">
+ RFC - Post Office Protocol - Version 3
+ </a> </li>
+ <li> <a href="checkimap.html">Check IMAP</a> </li>
+ <li> <a href="checksmtp.html">Check SMTP</a> </li>
+ <li> <a href="checkcaldav.html">Check Caldav</a> </li>
+ <li> <a href="checkcarddav.html">Check Carddav</a> </li>
+ <li> <a href="checkldap.html">Check LDAP</a> </li>
+ </ul>
+ </subsection>
+ </section>
+ <section>
+ </section>
+</body>
+</document>
Index: src/site/resources/plaintext/checkpop.py.text
===================================================================
--- src/site/resources/plaintext/checkpop.py.text (nonexistent)
+++ src/site/resources/plaintext/checkpop.py.text (working copy)
@@ -0,0 +1,95 @@
+# Python script
+# on davmail website as checkpop.py.text
+# store on your computer as checkpop.py
+# invoke as `python checkpop.py username password`, example given
+# python checkpop.py mrose secret
+#
+# Intented use case is a quick check on POP function of Davmail.
+# host and port are localhost and 1110
+# change those variables below for your configuration, if needed.
+# Nice side effects:
+# * Easy password guessing, more likely easy account name guessing.
+# You are supposed to have access granted to a Microsoft exchange server.
+# * Have allready some Python code in the documentation.
+# For 'POP' is this script overkill,
+# for 'LDAP' can this Python script a reference implementation
+#
+#
+# DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway check script
+# Copyright (C) 2017 Geert Stappers
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+import socket
+import poplib
+import sys
+
+import traceback,pprint
+
+host = 'localhost'
+port = 1110
+
+def checkpop(user,password):
+ """connects to POP service
+ does a login and reports number of messages
+ then closes connections
+ all wrapped in exception handler
+ """
+ try:
+ myconn = poplib.POP3(host,port)
+ myconn.set_debuglevel(0) # 0: nothing, 1: moderate, 2: much debug output
+ myconn.getwelcome() # greeting string sent by the POP3 server.
+ myconn.user(user)
+ myconn.pass_(password)
+ (count, size) = myconn.stat()
+ myconn.rset() # Unmark all messages marked for deletion. Better save
+ # then sorry
+ myconn.quit() # Signoff:
+ # * commit changes
+ # * unlock mailbox
+ # * connection.
+ """ Now handle exceptions, if any ..."""
+ except poplib.error_proto:
+ type, value, tb = sys.exc_info()
+ sys.stderr.write((str(value) + "\n"))
+ sys.exit(1)
+ except socket.error:
+ type, value, tb = sys.exc_info()
+ sys.stderr.write((str(value) + "\n"))
+ sys.exit(1)
+ except:
+ """
+ "Catch all exception" for unknown situations.
+ Please report these, especially if you can reproduce it
+ """
+ type, value, tb = sys.exc_info()
+ sys.stderr.write("!! yet unknown exception\n")
+ pprint.pprint(type)
+ print("\n" + ''.join(traceback.format_exception(type, value, \
+ tb)).strip("\n"))
+ print("tb " + str(tb) + "\n")
+ print("value " + str(value) + "\n")
+ sys.exit(2)
+ print("message count is %d, message size is %d") % ( count, size )
+ return
+
+if __name__ == '__main__':
+ if len(sys.argv) >= 2:
+ checkpop(sys.argv[1],sys.argv[2])
+ else:
+ sys.stderr.write("Provide username and password as parameters\n")
+
+# l l
Index: src/site/resources/plaintext/README.text
===================================================================
--- src/site/resources/plaintext/README.text (nonexistent)
+++ src/site/resources/plaintext/README.text (working copy)
@@ -0,0 +1,8 @@
+
+In this directory website resources
+that a webserver should present as plain text.
+
+The idea of the "filename extension" '.text',
+is to get MIME type text/plain.
+
+# l l
Geert Stappers
2017-01-07 18:12:46 UTC
Permalink
Post by Geert Stappers
Here is allready the output of `svn status`
|$ svn status src/site/
|A src/site/resources/plaintext
|A src/site/resources/plaintext/README.text
|A src/site/resources/plaintext/checkpop.py.text
|M src/site/site.xml
|A src/site/xdoc/checkpop.xml
The same output reordered and edited
|Modified src/site/site.xml
|Added file src/site/xdoc/checkpop.xml
|Added directory src/site/resources/plaintext
|Added file src/site/resources/plaintext/checkpop.py.text
|Added file src/site/resources/plaintext/README.text
Those new files, could they get MIME type 'text/plain' in SVN?

Quoting http://svnbook.red-bean.com/en/1.7/svn.advanced.props.file-portability.html#svn.advanced.props.special.mime-type

Additionally, since the acts of displaying line-based differences and
line-based change attribution are, rather obviously, dependent on there
being a meaningful definition of "line" for a given file, files with
nontextual MIME types will by default trigger errors when used as the
targets of svn diff and svn annotate operations. This can be especially
frustrating for users with XML files whose svn:mime-type property is
set to something such as application/xml which is not unambiguously
human-readable and as such is treated as nontextual by Subversion.


Groeten
Geert Stappers
--
Leven en laten leven
Geert Stappers
2017-01-16 20:35:14 UTC
Permalink
Post by Geert Stappers
Hello,
Thing I miss in the documentation, is how to check the connection
that Davmail makes.
At http://davmail.sourceforge.net/ there is "Davmail setup"
and "Thunderbird setup" plus other client setups.
... new files and change on the toplevel XML file ...
Post by Geert Stappers
Could this be added to Davmail SVN repository?
ping

Loading...