2 import org.ibex.mail.target.*;
3 import org.ibex.mail.protocol.*;
4 import org.ibex.util.*;
12 public static class Resin {
13 new extends com.caucho.server.port.Protocol() {
14 public String getProtocolName() { return "imap"; }
15 public com.caucho.server.port.ServerRequest createRequest(com.caucho.server.connection.Connection conn) {
17 return new Listener(conn);
18 } catch (Exception e) {
26 public String getProtocolName() { return "smtp"; }
27 public com.caucho.server.port.ServerRequest createRequest(com.caucho.server.connection.Connection conn) {
29 return new Server(conn);
30 } catch (Exception e) {
38 public static void main(String[] s) throws Exception {
41 String logto = System.getProperty("ibex.mail.root", File.separatorChar + "var" + File.separatorChar + "org.ibex.mail");
42 logto += File.separatorChar + "log";
47 new IMAPThread().start();
48 new SMTPThread().start();
52 public static class BogusAuthenticator implements IMAP.Server.Authenticator {
54 FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT, true).slash("user", true).slash("megacz", true);
55 public Mailbox authenticate(String u, String p) {
56 if (u.equals("megacz") && p.equals("pass")) return root;
61 private static class IMAPThread extends Thread {
62 final int port = Integer.parseInt(System.getProperty("ibex.mail.imap.port", "143"));
65 Log.info(this, "binding to port " + port + "...");
66 ServerSocket ss = new ServerSocket(port);
67 Log.info(this, "listening for connections...");
69 final Socket sock = ss.accept();
73 new IMAP.Listener(sock, "megacz.com", new BogusAuthenticator()).handle();
74 } catch (Exception e) {
80 } catch (Exception e) {
86 private static class SMTPThread extends Thread {
87 final int port = Integer.parseInt(System.getProperty("ibex.mail.smtp.port", "25"));
90 Log.info(this, "binding to port " + port + "...");
91 ServerSocket ss = new ServerSocket(port);
92 Log.info(this, "listening for connections...");
94 final Socket sock = ss.accept();
95 final SMTP.Server smtp = new SMTP.Server(sock, "megacz.com");
100 } catch (Exception e) {
106 } catch (Exception e) {