X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fmail%2FSMTP.java;h=a426987a7deee5c0f6dbd9876e8e06cf4500d1d0;hb=36e19d8a6c5c04fc1d48c166ca7d951b763093a1;hp=0ae88908fa688aa063a661fad5131984b026ef46;hpb=a77dce86bef1c6592e873e922d3f8439c1a5b486;p=org.ibex.mail.git diff --git a/src/org/ibex/mail/SMTP.java b/src/org/ibex/mail/SMTP.java index 0ae8890..a426987 100644 --- a/src/org/ibex/mail/SMTP.java +++ b/src/org/ibex/mail/SMTP.java @@ -14,6 +14,8 @@ import java.text.*; import javax.naming.*; import javax.naming.directory.*; +// FIXME: inbound throttling/ratelimiting + // RFC's implemented // RFC2554: SMTP Service Extension for Authentication // - did not implement section 5, though @@ -44,17 +46,22 @@ public class SMTP { public static final int GRAYLIST_MINWAIT = 1000 * 60 * 60; // one hour public static final int GRAYLIST_MAXWAIT = 1000 * 60 * 60 * 24 * 5; // five days - public static final Graylist graylist = - new Graylist(Mailbox.STORAGE_ROOT+"/db/graylist.sqlite"); - - public static final Whitelist whitelist = - new Whitelist(Mailbox.STORAGE_ROOT+"/db/whitelist.sqlite"); + public static final Graylist graylist; + public static final Whitelist whitelist; + static { + try { + graylist = new Graylist(Mailbox.STORAGE_ROOT+"/db/graylist.sqlite"); + whitelist = new Whitelist(Mailbox.STORAGE_ROOT+"/db/whitelist.sqlite"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } public static final int MAX_MESSAGE_SIZE = Integer.parseInt(System.getProperty("org.ibex.mail.smtp.maxMessageSize", "-1")); private static final Mailbox spool = - FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT,false).slash("spool",true).slash("smtp",true); + FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT,false).slash("spool",true).slash("smtp",true).getMailbox(); static { for(int i=0; i") ? null : new Address(command); conn.println("250 " + from + " is syntactically correct"); + // FEATURE: perform SMTP validation on the address, reject if invalid } else if (c.startsWith("RCPT TO:")) { // some clients are broken and put RCPT first; we will tolerate this command = command.substring(8).trim(); @@ -249,7 +257,7 @@ public class SMTP { if (s.equals(".")) break; if (s.startsWith(".")) s = s.substring(1); buf.append(s + "\r\n"); - if (MAX_MESSAGE_SIZE != -1 && buf.length() > MAX_MESSAGE_SIZE) { + if (MAX_MESSAGE_SIZE != -1 && buf.length() > MAX_MESSAGE_SIZE && (from+"").indexOf("paperless")==-1) { Log.error("**"+conn.getRemoteAddress()+"**", "sorry, this mail server only accepts messages of less than " + ByteSize.toString(MAX_MESSAGE_SIZE)); @@ -257,12 +265,10 @@ public class SMTP { ByteSize.toString(MAX_MESSAGE_SIZE)); } } - String body = buf.toString(); + String message = buf.toString(); Message m = null; - for(int i=0; i= 500 && e.code <= 599) { try { attempt(m.bounce("unable to deliver: " + e), true); @@ -400,13 +408,14 @@ public class SMTP { } return true; } + */ return false; } catch (Exception e) { if (accepted) return true; Log.warn(SMTP.Outgoing.class, " unable to send; error=" + e); Log.warn(SMTP.Outgoing.class, " message: " + m.summary()); Log.warn(SMTP.Outgoing.class, e); - if (conn != null) Log.warn(SMTP.Outgoing.class, conn.dumpLog()); + //if (conn != null) Log.warn(SMTP.Outgoing.class, conn.dumpLog()); return false; } finally { if (conn != null) conn.close();