// FIXME: loop prevention
// FIXME: probably need some throttling on outbound mail
-// graylisting?
-
// FEATURE: infer messageid, date, if not present (?)
// FEATURE: exponential backoff on retry time?
// FEATURE: RFC2822, section 4.5.1: special "postmaster" address
public static final int GRAYLIST_MAXWAIT = 1000 * 60 * 60 * 24 * 5; // five days
public static final Graylist graylist =
- new Graylist(Mailbox.STORAGE_ROOT+"/graylist.sqlite");
+ new Graylist(Mailbox.STORAGE_ROOT+"/db/graylist.sqlite");
+
+ public static final Whitelist whitelist =
+ new Whitelist(Mailbox.STORAGE_ROOT+"/db/whitelist.sqlite");
public static final int MAX_MESSAGE_SIZE =
Integer.parseInt(System.getProperty("org.ibex.mail.smtp.maxMessageSize", "-1"));
// Server //////////////////////////////////////////////////////////////////////////////
public static class Server {
- public void handleRequest(Connection conn) {
+ public void handleRequest(Connection conn) throws IOException {
conn.setTimeout(5 * 60 * 1000);
conn.setNewline("\r\n");
conn.println("220 " + conn.vhost + " SMTP " + this.getClass().getName());
String remotehost = null;
for(String command = conn.readln(); ; command = conn.readln()) try {
if (command == null) return;
- Log.warn("**"+conn.getRemoteAddress()+"**", command);
+ //Log.warn("**"+conn.getRemoteAddress()+"**", command);
String c = command.toUpperCase();
if (c.startsWith("HELO")) {
remotehost = c.substring(5).trim();
} else {
conn.println("551 sorry, " + addr + " is not on this machine");
}
+ conn.flush();
} else if (c.startsWith("DATA")) {
//if (from == null) { conn.println("503 MAIL FROM command must precede DATA"); continue; }
if (to == null || to.size()==0) { conn.println("503 RCPT TO command must precede DATA"); continue; }
} catch (MailException.Malformed mfe) { conn.println("501 " + mfe.toString());
} catch (MailException.MailboxFull mbf) { conn.println("452 " + mbf);
} catch (Later.LaterException le) { conn.println("453 try again later");
- } catch (IOException ioe) {
- //conn.println("554 " + ioe.toString());
- Log.error(this, ioe);
- conn.close();
- return;
}
} else { conn.println("500 unrecognized command"); }
} catch (Message.Malformed e) { conn.println("501 " + e.toString()); }
}
}
synchronized(Outgoing.class) {
- spool.add(m);
+ spool.insert(m, Mailbox.Flag.defaultFlags);
Outgoing.class.notifyAll();
}
}