diff --git a/build.xml b/build.xml
index 31324f9d..462eeeae 100644
--- a/build.xml
+++ b/build.xml
@@ -44,6 +44,7 @@
+
@@ -63,6 +64,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/servlet-api.jar b/lib/servlet-api.jar
new file mode 100644
index 00000000..70351218
Binary files /dev/null and b/lib/servlet-api.jar differ
diff --git a/src/java/davmail/DavGateway.java b/src/java/davmail/DavGateway.java
index 41a977c1..fbd0a424 100644
--- a/src/java/davmail/DavGateway.java
+++ b/src/java/davmail/DavGateway.java
@@ -35,22 +35,7 @@ public class DavGateway {
public static void start() {
// first stop existing servers
- if (smtpServer != null) {
- smtpServer.close();
- try {
- smtpServer.join();
- } catch (InterruptedException e) {
- DavGatewayTray.warn("Exception waiting for listener to die", e);
- }
- }
- if (popServer != null) {
- popServer.close();
- try {
- popServer.join();
- } catch (InterruptedException e) {
- DavGatewayTray.warn("Exception waiting for listener to die", e);
- }
- }
+ DavGateway.stop();
int smtpPort = Settings.getIntProperty("davmail.smtpPort");
if (smtpPort == 0) {
smtpPort = SmtpServer.DEFAULT_PORT;
@@ -74,4 +59,23 @@ public class DavGateway {
}
+ public static void stop() {
+ if (smtpServer != null) {
+ smtpServer.close();
+ try {
+ smtpServer.join();
+ } catch (InterruptedException e) {
+ DavGatewayTray.warn("Exception waiting for listener to die", e);
+ }
+ }
+ if (popServer != null) {
+ popServer.close();
+ try {
+ popServer.join();
+ } catch (InterruptedException e) {
+ DavGatewayTray.warn("Exception waiting for listener to die", e);
+ }
+ }
+ }
+
}
diff --git a/src/java/davmail/web/DavGatewayServletContextListener.java b/src/java/davmail/web/DavGatewayServletContextListener.java
new file mode 100644
index 00000000..e5c9d8c3
--- /dev/null
+++ b/src/java/davmail/web/DavGatewayServletContextListener.java
@@ -0,0 +1,40 @@
+package davmail.web;
+
+import davmail.Settings;
+import davmail.DavGateway;
+import davmail.tray.DavGatewayTray;
+
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * Context Listener to start/stop DavMail
+ */
+public class DavGatewayServletContextListener implements ServletContextListener {
+ public void contextInitialized(ServletContextEvent event) {
+ InputStream settingInputStream = null;
+ try {
+ settingInputStream = DavGatewayServlet.class.getClassLoader().getResourceAsStream("davmail.properties");
+ Settings.load(settingInputStream);
+ DavGateway.start();
+ } catch (IOException e) {
+ DavGatewayTray.error("Error loading settings file from classpath: ", e);
+ } finally {
+ if (settingInputStream != null) {
+ try {
+ settingInputStream.close();
+ } catch (IOException e) {
+ DavGatewayTray.debug("Error closing configuration file: ", e);
+ }
+ }
+ }
+ DavGatewayTray.debug("DavMail Gateway started");
+ }
+
+ public void contextDestroyed(ServletContextEvent event) {
+ DavGatewayTray.debug("Stopping DavMail Gateway...");
+ DavGateway.stop();
+ }
+}
diff --git a/src/web/WEB-INF/classes/davmail.properties b/src/web/WEB-INF/classes/davmail.properties
new file mode 100644
index 00000000..1299c97d
--- /dev/null
+++ b/src/web/WEB-INF/classes/davmail.properties
@@ -0,0 +1,11 @@
+davmail.url=http://exchangeServer/exchange/
+davmail.popPort=1110
+davmail.smtpPort=1025
+davmail.keepDelay=30
+davmail.allowRemote=true
+davmail.enableProxy=false
+davmail.proxyHost=
+davmail.proxyPort=
+davmail.proxyUser=
+davmail.proxyPassword=
+davmail.server=true
diff --git a/src/web/WEB-INF/web.xml b/src/web/WEB-INF/web.xml
new file mode 100644
index 00000000..5e2c3558
--- /dev/null
+++ b/src/web/WEB-INF/web.xml
@@ -0,0 +1,18 @@
+
+
+
+ Ever wanted to get rid of Outlook ? DavMail is a POP/SMTP exchange gateway allowing
+ users to use any mail client (e.g. Thunderbird) with an Exchange server, even from the internet
+ through Outlook Web Access. DavMail gateway is implemented in java and should run on
+ any platform. Releases are tested on Windows and Linux (Ubuntu). MacOS support is currently
+ limited to server (headless) mode. Tested successfully with the Iphone (gateway running on a
+ server).
+
+
+ davmail.web.DavGatewayServletContextListener
+
+